示例
StreamingURLResourceExample.as
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import org.osmf.elements.VideoElement;
import org.osmf.media.MediaPlayerSprite;
import org.osmf.net.StreamType;
import org.osmf.net.StreamingURLResource;
public class StreamingURLResourceExample extends Sprite
{
public function StreamingURLResourceExample()
{
super();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite();
var videoElement:VideoElement = new VideoElement();
//StreamType一定要设置正确,如果为Recorded,就要进行相应设置。(可以设置成通用的StreamType.LIVE_OR_RECORDED)。
//后面的参数True/False,表示,"rtmp://localhost/live/stream"这段字符串是否包含实例,比如我们的live是一个application.但没有instance,则使用默认的instance:_default_。否则如"rtmp://localhost/live/instance/stream“,则应该设置为true。当前的实例为instance videoElement.resource = new StreamingURLResource("rtmp://localhost/live/stream", StreamType.LIVE,NaN,NaN,null,false);
addChild(mediaPlayerSprite); mediaPlayerSprite.media = videoElement; } } }