package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;

    //播放FLV视频    
    public class Main extends Sprite
    {        
        var stream:NetStream;
        
        public function Main():void
        {
            //第一步:创建通道,打开通道
            var conn:NetConnection = new NetConnection();            
            conn.connect(null);
            
            //第二步:创建流处理,指定回调函数为本身
            stream = new NetStream(conn);
            var obj:Object = new Object();
            stream.client = obj;
            
            //第三步:视频流的呈现,绑定视频流
            var video:Video = new Video(200,150);
            video.attachNetStream(stream);
            this.addChild(video);
            stream.play("sp.flv");
            
            //用按钮控制视频播放和停止
            var s:Sprite = new Sprite();
            s.graphics.beginFill(0xff0000);
            s.graphics.drawRect(0,0,50,50);
            s.graphics.endFill();
            s.y = 150;
            this.addChild(s);
            s.addEventListener(MouseEvent.CLICK, an);
        }
        private function an(evt:MouseEvent):void
        {
            stream.togglePause();
            
        }
    }
}

相关文章:

  • 2021-06-10
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2021-09-26
  • 2022-01-20
  • 2022-02-28
  • 2021-06-30
相关资源
相似解决方案