StageVideo问题

时间:2015-12-14 16:07:26

标签: actionscript-3 stagevideo

我尝试了一些建立在网络上的例子但是没有用...... 代码:

package{
import flash.display.Sprite;
import flash.events.StageVideoAvailabilityEvent;
import flash.media.StageVideo;
import flash.events.StageVideoEvent;
import flash.geom.Rectangle;
import flash.media.StageVideoAvailability;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.display.DisplayObjectContainer;

public class myStageVideo extends Sprite{

    private var stageVideoAvail:Boolean;
    private var sv:StageVideo;

    public function myStageVideo(container:DisplayObjectContainer){
        container.addChild(this);
        container.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onAvail);
    }

    private function onAvail(e:StageVideoAvailabilityEvent):void{
        trace("arrivato a onAvail");
        stageVideoAvail = (e.availability == StageVideoAvailability.AVAILABLE);
        initVideo();
    }

    private function initVideo():void{
        var nc:NetConnection = new NetConnection();
        nc.connect(null);
        var ns:NetStream = new NetStream(nc);
        ns.client = this;
        stageVideoAvail = true;
        if(stageVideoAvail){
            sv = stage.stageVideos[0];
            sv.addEventListener(StageVideoEvent.RENDER_STATE, onRender);
            sv.attachNetStream(ns);
            trace('available');
        }
        else{
            var vid:Video = new Video(1024, 768);
            addChild(vid);
            vid.attachNetStream(ns);
            trace('not');
        }

        ns.play('video.mp4');
    }

    private function onRender(e:StageVideoEvent):void{
        sv.viewPort = new Rectangle(0, 0, 1024, 768);
    }

    public function onMetaData(e:Object):void{

    }

    public function onXMPData(e:Object):void{

    }
    }
}
我做错了什么?我试着从一个星期开始,但没什么...... video.mp4在同一个文件夹中。 我认为1错误 这是我将孩子添加到容器的方式

0 个答案:

没有答案