Flash 可以播放 .avi 或 .mpg4 吗?如果是,怎么办?

发布于 2024-11-13 09:38:49 字数 1788 浏览 1 评论 0原文

如何在Flash中加载和播放.avi或.mpg4?这可能吗?

->该类可以播放 .flv 和 .mp4 .. 但对于 .avi 它显示错误“错误 #2044:未处理的 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;           
                //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; 
            }
        } 
}

.. 有任何帮助吗?

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;           
                //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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

感情废物 2024-11-20 09:38:49

如果文件是流媒体服务器上的 MP4,您只需在进行 RTMP 调用时在视频文件名前加上“mp4:”前缀即可。您需要确保仅将其添加到实际视频文件中,而不是完整的 URL。

示例:

如果您的完整视频位于 rtmp://domain.com/dir/myVideo.mp4,那么您在调用 play 时应添加前缀 myVideo.mp4 () 函数。

ns.play("mp4:myVideo");

根据流媒体服务器的设置,您可能需要也可能不需要文件扩展名。

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.

此生挚爱伱 2024-11-20 09:38:49

此示例可以播放.mp4文件

this example can play .mp4 files

还不是爱你 2024-11-20 09:38:49

文件扩展名实际上并没有多大意义。 AVI、QuickTime 等是容器格式,它们内部的音频和视频流格式(即编解码器)可能有所不同。对于某些容器,容器格式也可能有所不同。

Wikipedia 上的 Flash 视频 文章很好地总结了哪些内容可以在 Flash 版本中播放玩家。

至于播放视频,您可以使用 FLVPlayback 制作自己的播放器或者使用常见的播放器,例如 FlowPlayer

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文