|
SYS-CON Magazines
|
Top Three Links You Must Click On
Flash Using File Object for Video on Demand and MP3 Playback
One new feature of Flash Media Server 2 is the File Object feature
By: Robert Sandie
Feb. 26, 2006 05:00 PM
Flash Media Server 2 offers a unique combination of traditional streaming media capabilities and a flexible development environment for creating and delivering media experiences to your audiences. These include traditional media like video on demand, live web-event broadcasts, and MP3 streaming, as well as rich media communication applications like video blogging, video messaging, and multimedia chat environments.
In this article, you will learn about a rather simple application that lets you display FLVs and MP3s on demand with predefined components you build using Flash Professional 8. This application automatically grabs FLVs and MP3s from a specific location on your server but is extensible for other uses. For example, to customize this application for a photo album using JPEGs, you would just redefine the filter so it calls JPEGs. This application demonstrates new File Object properties on the server side and works in conjunction with the DataGrid, FLVPlayback, and MediaPlayback components on the client side. It demonstrates an alternative to XML-driven playback lists. If you wish to learn more about XML FLV lists, check out Lisa Larson's article, Creating a Dynamic Playlist for Streaming Video.
Setting Up Your Environment
Flash Media Server 2 has two applications that control the logic, FileObj and MyCollection. When OnDemandPlayer.swf is instantiated, it accesses FileObj, which returns the content into a DataGrid. When the user clicks an object in the DataGrid, it calls the video based in MyCollection.
Setting Up Flash Media Server
File Access
<FileObject> You have just enabled secure file access to this defined sandbox. You can set up multiple file object directories by consecutively adding virtual directories.
Stream Access
<VirtualDirectory>
Examining the Server-Side ActionScript
When you develop any Flash Media Server application, it is always easiest to start with the server-side ActionScript. Doing this allows you to debug and simulate the client-side actions using trace statements. This not only cuts down on your development time but prevents headaches later on. You may notice that there are extra functions in main.asc in your FileObj folder. Notice there is more server-side ActionScript than is required for this application. This is what I use to handle all the file access commands in a familiar framework or API. I hope you will find this code useful and repurpose it for future file access functions. Let's go over a few key functions in this file. Constructor for File Class this.myFile = new File(name); This construct command creates an instance of the file class as object myFile. The variable, name, can be either a file or directory. In this demonstration, you will be passing your alias directory into here to gather information about it (by default, approot). File.List for File Class var dirList = this.myFile.list(filter); This is the list function from which the DataGrid on the client side takes information. The list method returns an array with an element for each file in the directory. You can filter this further with the filter function:
function filter(name) Reader Feedback: Page 1 of 1
Subscribe to our RSS feeds now and receive the next article instantly!
Subscribe to the World's Most Powerful Newsletters
|
|
||||||||||||||||||||||||||||||||||