Search code examples
actionscript-3osmf

RTMP streaming with OSMF - AS3


New to OSMF and trying to play a streaming mp4 on our limelight server. According to this tutorial http://www.adobe.com/devnet/flash/articles/video_osmf_streaming.html, you simply pass the RTMP link to the URLResource. I've tried that and it isn't working. It plays fine if I pass a local URL. I am using OSMF 1.5 SWC and my code is

package 
{
    import flash.display.*;
    import flash.events.*;
    import org.osmf.media.*;

    public class Main extends Sprite
    {
        private var mps:MediaPlayerSprite;

        public function Main()
        {
            stage.align     = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            mps             = new MediaPlayerSprite();
            mps.width       = 640;
            mps.height      = 360;
            mps.resource    = new URLResource("rtmp://my.limelight.host.net/mp4:dyk_seatbelts_high.mp4");
            addChild(mps);
        }
    }
}

I dont get any errors just a blank canvas. Any ideas?


Solution

  • You should add streamer and video url for RTMP streaming. For example:

    var resource:DynamicStreamingResource = new DynamicStreamingResource(videoStreamer);
    resource.urlIncludesFMSApplicationInstance = true;
    var vector:Vector.<DynamicStreamingItem> = new Vector.<DynamicStreamingItem>(1);
    vector[0] = new DynamicStreamingItem(videoUrl, 1200);
    resource.streamItems = vector;
    element = new VideoElement(resource);
    
    player.media = element;
    

    You can add few dynamic streaming items. Video files with different bitrate.

    Example for videoStreamer: rtmp://streamer_url

    Example for videoUrl: mp4:path_to_video.mp4