Flash 可以播放 .avi 或 .mpg4 吗?如果是,怎么办?
如何在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果文件是流媒体服务器上的 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 prefixmyVideo.mp4
when you call theplay()
function.ns.play("mp4:myVideo");
Depending on your streaming server's settings you may or may not need the file extension.
此示例可以播放
.mp4
文件this example can play
.mp4
files文件扩展名实际上并没有多大意义。 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.