How can I load a FLV file into a MovieClip (lets call the instance "flvPlaceHolder") and start playing that FLV file.. using ActionScript 3?
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 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");
from here
To do this locally - cut and paste the following code in the first frame of your flash file. Of course change the name at the end.
stage.displayState = StageDisplayState.FULL_SCREEN;
var connection:NetConnection = new NetConnection();
var stream:NetStream;
var video:Video = new Video(1280,960);
var metaObj:Object = new Object();
function onMetaData(data:Object):void
{
}
connection.connect(null);
stream = new NetStream(connection);
stream.client = metaObj;
metaObj.onMetaData = onMetaData;
video.attachNetStream(stream);
addChild(video);
stream.play("name_of_flv.flv");
video.x = 0;
video.y = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With