如果将目录移动到其他位置,则.flv格式影片的实时流式传输无法正常工作

时间:2011-06-27 09:56:31

标签: actionscript-3 video-streaming streaming-flv-video

我可以在通过FlashDevelop编译后播放.flv电影,但如果我将整个目录移动到同一台PC中的另一台PC或另一台目录中,它就无法正常工作。非常感谢您的帮助......谢谢

package 

{
    import flash.display.Sprite;

    import flash.net.NetConnection;
    import flash.net.NetStream;  

    import flash.media.Video;
    public class Main extends Sprite {  

        private var nc:NetConnection;
        private var ns:NetStream;
        private var vid:Video;
        private var client:Object;
        public function Main () {
            // Initialize net stream
            nc = new NetConnection();
            nc.connect (null); // Not using a media server.
            ns = new NetStream(nc);
            // Add video to stage
            vid = new Video(320,240);
            addChild (vid);
            //vid.x = ( stage.stageWidth / 2) - ( vid.width / 2 );
            //vid.y = ( stage.stageHeight / 2) - ( vid.height / 2 );
            // Changed since when deployed the
           // above set the video player nearly off the screen
           // Since I am lazy, I am just going to 0 them
           // out for now. Apparently, I have a lot more
           // to learn.
          vid.x = 0;
          vid.y = 0;  

          // Add callback method for listening on
          // NetStream meta data
          client = new Object();
          ns.client = client;
          client.onMetaData = nsMetaDataCallback;
          // Play video
          vid.attachNetStream ( ns );
          ns.play ( 'dancinggirl_1.flv' );
        }
        //MetaData
        private function nsMetaDataCallback (mdata:Object):void {
            trace (mdata.duration);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您必须指定flv所在的路径,并确保flv位于此swf的相对路径中。

ns.play ( 'path/to/dancinggirl_1.flv' );

如果您将swf嵌入到HTML页面中。路径必须相对于HTML而不是swf文件。