Reputation: 182
I have a flash app that is going to be run in full screen from an swf. I need to play a video over the content when user does click in a button. I hear audio from the net stream, but I do not see the video. I've tried with flv and mp4 files, all in the same folder than the swf.
Here's my code:
var my_video:Video;
my_video = new Video();
my_video._height=600;
my_video._width=800;
my_video._x = 0;
my_video._y = 0;
addChild(my_video);
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("video.mp4");
Thank you very much.
Upvotes: 0
Views: 2577
Reputation: 8111
You need a component in your library, it depends on your version of the IDE. Either Video, MediaDisplay or the more recent FLVPlayback all work in AS2. Then you will see video.
Ok if you create a new AS2 file in CS5.5 then open the components panel you can double click the FLVPlayback component and it will put it on the stage and in your library, just delete the one off the stage as you can attach it with code, you just need it in the library to use it.
The following code will demonstrate this working:
import mx.video.FLVPlayback;
var video:FLVPlayback = this.attachMovie("FLVPlayback", "my_video", 10);
video.contentPath = "http://www.helpexamples.com/flash/video/water.flv";
video.setSize(640, 480);
Have a look at the documentation to help you understand what properties are available to help you understand how this component works:
Upvotes: 1