开发者

Does flash play .avi or .mpg4 ? If yes, how?

How to load and play .avi or .mpg4 in Flash? Is that possible ?

-> This class can play .flv and also .mp4 .. but for .avi it shows error "Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound"

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

        public class vplayer extends Sprite{                 
            public var vid:Video = new Video(1920,1080);
            private var nc:NetConnection = new NetConnection();
            public var ns:NetStream;
            public var listener:Object = new Object();
            private var _duration:Number = 0; 

            public function vplayer():void{             
                addChild(vid);
                nc.connect(null);
                ns = new NetStream(nc);
                vid.attachNetStream(ns);
                listener.onMetaData = metaDataHandler;
                ns.client = listener;开发者_如何学Python           
                //customClient.onCuePoint = cuePointHandler;
            }
            public function playVideo00(vv:String):void{

                ns.play(vv);
            }
            public function stopVideo00():void{
                ns.close();
            }
            /*public function cuePointHandler(infoObject:Object):void {
                trace("cuePoint");
            }*/
            public function metaDataHandler(infoObject:Object):void {
                _duration = infoObject["duration"];
                trace (" Time:  " + infoObject["duration"]);
            }
            public function get duration00():Number {     
                return _duration; 
            }
        } 
}

.. any help ?


If the file is an MP4 on a streaming server, you simply need to prefix your video file name with "mp4:" when making the RTMP call. You need to be sure to only add it to the actual video file, not the full URL.

Example:

If your full video is at rtmp://domain.com/dir/myVideo.mp4 then you would prefix myVideo.mp4 when you call the play() function.

ns.play("mp4:myVideo");

Depending on your streaming server's settings you may or may not need the file extension.


this example can play .mp4 files


File extension actually doesn't mean that much. AVI, QuickTime, etc are container formats and the audio and video stream formats (ie, codecs) inside them can vary. With some, the container format can vary, too.

The Flash Video article on Wikipedia summarizes things fairly well as far as what is playable in what version of Flash Player.

As far as playing video, you can either make your own player using FLVPlayback or use a common player like FlowPlayer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜