Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Using File Object for Video on Demand and MP3 Playback
One new feature of Flash Media Server 2 is the File Object feature

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.

One new feature of Flash Media Server 2 is the File Object feature, which enables real-time read/write file access to a defined sandbox on your server, enabling content management systems and database applications without using Flash Remoting. This is a simple example that you can expand for use with File Object applications.

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
To follow this code walkthrough, you will need on_demand_player.zip, the sample file download that accompanies this article. Here's what you should do with the contents of the ZIP archive:

  • Place the FileObj and MyCollection folders in your Flash Media Server applications directory (by default, this is Flash Media Server 2\applications\).
  • Put the OnDemandPlayer folder anywhere on your development machine.
  • Place the MP3s and FLVs that you want to stream into the MyCollection/streams/_definst_/ folder.
It's easy to change your default applications folder. Open conf/fms.ini in a text editor and change the variable VHOST.APPSDIR.

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
To make this application to work, you need to configure File Access and Stream Access.

File Access
The File Object class allows access to a sandbox within your server file system. To protect against any misuse, Flash Media Server allows access to files within a sandbox specified for the virtual host where the application instance is running. To define your server-side sandbox, go into your application.xml file in the FileObj folder. Define where you are storing the FLVs and MP3s that you wish the server to find:

<FileObject>

   <VirtualDirectory>/approot; C:\Program Files\Macromedia\Flash Media Server
2\applications\MyCollection\streams\_definst_\

   </VirtualDirectory>
</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
You will also need to set up your Vhost.xml, which you can find in your conf/_defaultRoot_/_defaultVhost_/ subfolder in the Flash Media Server 2 folder because you must tell the server when you call "/approot" from the Vhost instance that it should look in the specified directory. You will need to define where you streams are located (should be the same as the setting you defined earlier for FileObject):

<VirtualDirectory>

   <Streams>/approot; C:\Program Files\Macromedia\Flash Media Server
2\applications\MyCollection\streams\_definst_\

   </Streams>

</Virtual Directory>

Examining the Server-Side ActionScript
There are two applications running on the Flash Media Server:

  • FileObj supports file access and filter functions pointing to your stream sandbox.
  • MyCollection supports FLVPlayback component functions.
Both run using the same default server-side ActionScript file, main.asc.

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)

{
if ( name.lastIndexOf( ".flv") != -1 || name.lastIndexOf(".mp3") != -1){
     return true;
    }
     return false;
}

About Robert Sandie
Robert Sandie interned at Macromedia as a product manager for the Flash Media Server team. He recently earned his degree in Computer Science and Business from Lehigh University in Bethlehem, Pennsylvania, where he also played football for the Mountain Hawks. Robert has a wealth of experiencing leading Flash projects and developing Flash video applications. To view his latest endeavors, catch up with him at robertsandie.com.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Enterprise Open Source Magazine Latest Stories . . .
With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
C12G Labs has just announced an update release of OpenNebulaPro, the enterprise edition of the OpenNebula Toolkit. OpenNebula 3.2, released two weeks ago, brings important benefits to cloud providers with a new easily-customizable self-service portal for cloud consumers, and builders w...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE