我想为流畅的流媒体元素创建序列组合,其中媒体元素的某些特定部分来自多个或单个清单(.isml)。我尝试使用isml包含该剪辑部分从10秒到50秒开始创建序列合成,然后在序列合成中添加下一个元素,以便从其他清单中播放50秒到150秒的部分。但不是播放指定的清单部分它从头到尾播放,一旦播放第一个isml,它就不会切换到序列组成的下一个元素。当它检查它正在处理mozila上的火虫时,我发现碎片请求是连续发送的,但玩家无法显示它。
代码: -
包 {
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);
}
}
}
谢谢