且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Flash/ActionScript 3:将 .FLV 文件加载到 MovieClip 中并开始播放该 FLV 文件

更新时间:2023-10-26 23:38:04

没有明确回答您的问题,但是有许多开源 FLV 播放器.我会通过抓住其中一个并查看它们如何处理播放视频来解决这个问题.

Not explicitly answering your question, but there are a number of open source FLV players in the wild. I'd approach the problem by grabbing one of those and seeing how they handle playing video.

FPlayer 将是一个很好的起点.这里是课程 正在做的工作.这是相当直接的,但使用这样的项目可能会为您节省一些时间.

FPlayer would be an excellent starting point. Here is the class that is doing the work. It is fairly straight forward, but using a project like this would probably save you some time.

这个片段应该以一种非常简单的方式来解决问题:

This snippet should do the trick in an extremely bare bones fashion:

var vid:Video = new Video(320, 240);
addChild(vid);

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
vid.attachNetStream(ns);

var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;

ns.play("externalVideo.flv");

从这里