OSMF serial composition with smooth streaming media element

530 views Asked by At

I want to create serial composition for smooth streaming media element with some specific portion of media element from multiple or single manifest(.isml). I have try to create serial composition with isml contain that clip section start from 10 sec to 50 sec and then add next element in serial composition for play 50 sec to 150 sec section from other manifest. but instead of play specified portion of manifest It play from start to end and once the first isml played it is not switch to next element of serial composition. when it check it's working on fire bug on mozila I found that fragment request is send continuously but player not able to show it.

code :-

package {

import flash.display.*;
import com.microsoft.azure.media.AdaptiveStreamingPluginInfo;
import org.osmf.containers.MediaContainer;
import org.osmf.elements.SerialElement;
import org.osmf.elements.VideoElement;
import org.osmf.events.MediaErrorEvent;
import org.osmf.events.MediaFactoryEvent;
import org.osmf.events.MediaPlayerStateChangeEvent;
import org.osmf.layout.*;
import org.osmf.media.*;
import org.osmf.net.StreamType;
import org.osmf.net.StreamingURLResource;
import org.osmf.net.StreamingItemType;

[SWF(width="1024", height="768", backgroundColor='#ffffff')]
public class OSMFComposition extends Sprite
{
    public var _container:MediaContainer;
    public var _mediaFactory:DefaultMediaFactory;
    private var _mediaPlayerSprite:MediaPlayerSprite;

    private const Media_Url1:String="http://<media server>/Sintel/Sintel_H264.ism/manifest";
    private const Media_Url2:String="http://<media server>/PushToPublishPoint/test.isml/manifest";
    private const add1:String="assets/1.mp4"
    private const add2:String="assets/2.mp4"
    private var serialElement:SerialElement;
    private var mediaPlayer:MediaPlayer;
    private var container:MediaContainer;

    public function OSMFComposition()
    {

        serialElement=new SerialElement();

        mediaPlayer=new MediaPlayer();

        stage.quality = StageQuality.HIGH;

        initMediaPlayer();

    }

    private function initMediaPlayer():void
    {

        // Create a mediafactory instance
        _mediaFactory = new DefaultMediaFactory();

        // Add the listeners for PLUGIN_LOADING
        _mediaFactory.addEventListener(MediaFactoryEvent.PLUGIN_LOAD,onPluginLoaded);

        // Load the plugin class 
        loadAdaptiveStreamingPlugin( );  

    }

    private function loadAdaptiveStreamingPlugin( ):void
    {
        var pluginResource:MediaResourceBase;

        pluginResource = new PluginInfoResource(new AdaptiveStreamingPluginInfo( ));

        _mediaFactory.loadPlugin( pluginResource ); 
    }

    private function onPluginLoaded( event:MediaFactoryEvent ):void
    {
        // The plugin is loaded successfully.
        // Your web server needs to host a valid crossdomain.xml file to allow plugin to download Smooth Streaming files.
        loadMediaSource();

    }



    private function loadMediaSource():void 
    {
        var preRoll:MediaElement = _mediaFactory.createMediaElement( new URLResource(add1) );

        var preRoll2:MediaElement = _mediaFactory.createMediaElement( new URLResource(add2) );

        var resource1:StreamingURLResource=new StreamingURLResource(Media_Url1,null,10,50);

        var element1:MediaElement = _mediaFactory.createMediaElement( resource1 );

        var resource2:StreamingURLResource= new StreamingURLResource(Media_Url2,null,150,200);

        var element2:MediaElement = _mediaFactory.createMediaElement( resource2 );

        serialElement.addChild( preRoll);

        serialElement.addChild(element2);

        serialElement.addChild( preRoll2);

        serialElement.addChild(element1);

        mediaPlayer=new MediaPlayer(serialElement);

        container=new MediaContainer();

        container.addMediaElement(serialElement);

        this.addChild(container);
    }     

}

}

Thanks

0

There are 0 answers