FORUMS: list search recent posts

Play flv video with click of a button

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Aisha Nelson
Play flv video with click of a button
on Oct 28, 2009 at 5:25:34 pm

I am trying make a video playlist. When a thumbnail (button) is clicked, I would like for it to play a specific flv video. What is the code for this action using AS3? Please help!!

Thanks in advance!


Return to posts index

Peter Mackay
Re: Play flv video with click of a button
on Oct 31, 2009 at 4:31:57 pm

Aisha, I have just done exactly the same thing, I'm not near the computer with the Flash project on it at the moment. So I cant send you the exact code right now. But basically you will need to put an instance of the FLV player on the stage, set up to the same dimensions as your video. This is empty, that is, no video is assigned to it until a button is clicked. I have six buttons above the player each one is assigned to a different video. You will create a mouse event listening for the click and at that point the function that you also need to create will assign the correct video to the player. I will post again later with the actual code, but this description should get you started.







Return to posts index

Aisha Nelson
Re: Play flv video with click of a button
on Nov 2, 2009 at 3:41:27 pm

Ok. Thanks I will try starting with this.Please send code when you get a chance. Is there a way I could also (using AS3) have commercials play in between each video?


Return to posts index


Saurav Gupta
Re: Play flv video with click of a button
on Oct 10, 2013 at 6:45:52 am

Hello
I am trying to do this exact same thing except I don't understand what you are saying here. Could you please explain this to me?
Thanks


Return to posts index

Peter Mackay
Re: Play flv video with click of a button
on Nov 2, 2009 at 5:54:30 pm

Ok here is the code that I am using to play video. You will have to adjust some of it to your situation. for instance video_mc is name of the flash movie clip that I am using to hold the FLVplayer as I am animating in the clip. You will be calling it something different, or you may not even have the player in a separate Movie Clip. My FLV clips reside in a folder called "videos" in the same folder as the project that way you do not need to embed the video into the SWF file making it too big to download quickly. I name the videos by number so that I can easily replace the video when I want to make a change, If you are not proposing to change the videos frequently you can just name them for what they are. My buttons have a thumbnail picture that represents the video, this can be achieved by putting an object called a UILOADER on top of the button this will load an image of your choice which will also live in a folder called "images" and these images need to be jpegs. I hope that this helps you with your project. Some one else will have to help you with the playing of commercials between the videos as I have not workout the code needed to do this I'm sure it can be done probably with an if/else function.

stop();

videoSeven_btn.addEventListener(MouseEvent.CLICK,videoSeven);
videoEight_btn.addEventListener(MouseEvent.CLICK,videoEight);
videoNine_btn.addEventListener(MouseEvent.CLICK,videoNine);
videoTen_btn.addEventListener(MouseEvent.CLICK,videoTen);
videoEleven_btn.addEventListener(MouseEvent.CLICK,videoEleven);
videoTwelve_btn.addEventListener(MouseEvent.CLICK,videoTwelve);



function videoSeven(evtObj:MouseEvent):void {
//this next line will show in the output window which button was clicked
trace("video Seven");
//this line tells the FLVPlayer whch video to play and where it is.
video_mc.videoPlayer.source="video/auto_video01.flv";
}

function videoEight(evtObj:MouseEvent):void {
trace("video Eight");
video_mc.videoPlayer.source="video/auto_video02.flv";
}

function videoNine(evtObj:MouseEvent):void {
trace("video Nine");
video_mc.videoPlayer.source="video/auto_video03.flv";
}

function videoTen(evtObj:MouseEvent):void {
trace("video Ten");
video_mc.videoPlayer.source="video/auto_video04.flv";
}

function videoEleven(evtObj:MouseEvent):void {
trace("video Eleven");
video_mc.videoPlayer.source="video/auto_video05.flv";
}

function videoTwelve(evtObj:MouseEvent):void {
trace("video Twelve");
video_mc.videoPlayer.source="video/auto_video06.flv";
}



Return to posts index

Aisha Nelson
Re: Play flv video with click of a button
on Nov 2, 2009 at 5:57:53 pm

Thank you so much Peter. I appreciate the feedback! I am going to try this. I'll let you know how it goes.


Return to posts index


Aisha Nelson
Re: Play flv video with click of a button
on Nov 5, 2009 at 9:44:42 pm

Peter thanks so much! That code worked great!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]