5 November 2010
Working knowledge of ActionScript 3 and Adobe Flash Builder or Adobe Flash Professional is recommended for this tutorial.
Intermediate
In this article you will create a simple multicast video player using the new features of Open Source Media Framework (OSMF) 1.5, Adobe Flash Player 10.1, and Adobe Flash Media Server 4. This article covers the basic building blocks used to create an OSMF multicast player, specifically focusing on the different classes that can be used or extended for multicast and Real-Time Media Flow Protocol (RTMFP) specific control.
Many of these steps can be simplified when using a MediaFactory object and an F4M manifest file, which we cover in Live multicast streaming using OSMF. The example in this article illustrates the underlying mechanisms needed instead of just a simple F4M implementation.
This article demonstrates the use of the following classes:
groupspec and streamName used for a P2P based multicast stream.You can use Adobe Flash Builder 4 or Adobe Flash Professional CS5 to complete the steps in this article. After downloading the sample files for this article, follow the steps below to get started.
If you're using Flash Builder:
If you're using Flash Professional:
Follow these steps to complete the OSMF_MulticastSample class:
//DECLARATIONS comment, make sure you see the following two variables: player typed as a MediaPlayer object and container typed as a MediaContainer object:public var player:MediaPlayer;
public var container:MediaContainer;
initPlayer() method. Under the comment that begins //Create a Group Specifier... , create a local variable named groupspec typed as a GroupSpecifier object.MULTICAST_GROUP static constant to the constructor for the GroupSpecifier object://Create a Group Specifier which manages the capabilities and requirements of the multicast group
var groupspec:GroupSpecifier = new GroupSpecifier( MULTICAST_GROUP );setPublishPassword() method on the groupspec object to set the password to "realeyes" :var groupspec:GroupSpecifier = new GroupSpecifier( MULTICAST_GROUP );
groupspec.setPublishPassword("realeyes");groupspec properties to true :multicastEnabledserverChannelEnabledYour code should look similar to the following:
//Create a Group Specifier which manages the capabilities...
var groupspec:GroupSpecifier = new GroupSpecifier( MULTICAST_GROUP );
groupspec.setPublishPassword("realeyes");
groupspec.multicastEnabled = true;
groupspec.serverChannelEnabled = true;
trace statement that outputs the "FMLE STREAM NAME".//Create a MulticastResource... create a new MulticastResource variable named multicastResource .urigroupspec.groupspecWithoutAuthorizations()streamNameYour code should look similar to the following:
//Create a MulticastResource to connect and manage the RTMFP Multicast.
var multicastResource:MulticastResource = new MulticastResource(uri, groupspec.groupspecWithoutAuthorizations(), streamName );
netLoader .element and pass multicastResource and netLoader to the VideoElement constructor. You code should look similar to the following://Create a MulticastNetLoader which manages the loading and RTMFP connection
var netLoader:MulticastNetLoader = new MulticastNetLoader()
//creates and sets the MediaElement (VideoElement) with a resource and...
var element:VideoElement = new VideoElement( multicastResource, netLoader );
player variable equal to a new MediaPlayer object.container variable equal to a new MediaContainer object.addMediaElement() method on the container object passing it the element object.addChild() method.The code should look like the following:
//the simplified api controller for media
player = new MediaPlayer( element );
//the container (sprite) for managing display and layout
container = new MediaContainer();
container.addMediaElement( element );
//Adds the container to the stage
this.addChild( container );
Follow these steps to set up the project for Flash Media Live Encoder:
livestream?fms.multicast.type=3&fms.multicast.groupspec=G%3A01012105f8cd...




For more information on multicast and OSMF, see the Open Source Media Framework Developer's Guide (PDF, 1 MB) or visit the Open Source Media Framework website. You may also want to explore the sample projects and templates in the Video Technology Center and the Flash Media Server Developer Center.
To learn how to streamline many of the steps covered in this article using the MediaFactory class and an F4M manifest file, read the companion article, Live multicast streaming using OSMF.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Tutorials & Samples |