6 Replies - 6139 Views - Last Post: 26 February 2009 - 01:21 AM

#1 michaelab  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 07-June 07

Two videos in one swf - how?

Posted 07 June 2007 - 05:06 PM

Here it is.

I have two videos: bending.flv and lifting.flv (I also have them in swf format).
I want the user to click play and for the videos to play one after the other, basically combining the videos
into one. However, I need to add a screen that says the second video is coming up after the first one finishes
playing. How do I do this? I am new to flash, have CS3 and could really use some help.

Thank you.
Is This A Good Question/Topic? 0
  • +

Replies To: Two videos in one swf - how?

#2 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Two videos in one swf - how?

Posted 08 June 2007 - 02:54 PM

Are you wanting to use ActionScript 3 (which requires Flash Player 9), or ActionScript 2?

For AS2, you can place the videos on separate frames, and then listen for the video's completion, to trigger the next video. .. Assuming you're using an FLVPlayback component named "theVideo", here's some code for your first video frame:

stop(); // stop the timeline, so we can watch the video.
theVideo.contentPath = "bending.flv"; // tell the FLVPlayback component what video to load

var myListener:Object = new Object(); // create an event listener
myListener.complete = function(evt:Object) { // create a function to handle the "complete" status
	play();
}
theVideo.addEventListener("complete", myListener); // assign the listener to the FLVPlayback component
theVideo.play(); // play the video

When the video ends, the "complete" status will be broadcast. The event listener will then 'hear' that status, and run the function defined to react to it. In this case, it simply tells the timeline to play, which would lead to the next frame. On that next frame, you could use the exact same code, but replace "bending.flv" with "lifting.flv".

You will then have a timeline that will play a video, play another video, and then continue on down the timeline. .. There are more appropriate ways to write this code, but this should give you a a good starting point to work from.

Now, if you're wanting to do this in AS3, then I don't know. I have not worked with video in AS3 yet, so I am unsure as to what has changed. I will need to tackle it tonight though, for a project I'm working on. So, if you can wait until tomorrow, then I can give you an AS3 sample to work with. Unless, of course, somebody else would like to chime in and save me some time tonight. :D
Was This Post Helpful? 0
  • +
  • -

#3 michaelab  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 07-June 07

Re: Two videos in one swf - how?

Posted 08 June 2007 - 03:46 PM

Hi di,

This is much appreciated. I will try it out on Monday when I'm at my work computer.

I have Flash CS3 so AS3 would be great also, but if not, I'll see how the AS2 works.

Thank you again, and I will get back to you after I've tried it out on Monday.

Michael

View PostDilutedImage, on 8 Jun, 2007 - 02:54 PM, said:

Are you wanting to use ActionScript 3 (which requires Flash Player 9), or ActionScript 2?

For AS2, you can place the videos on separate frames, and then listen for the video's completion, to trigger the next video. .. Assuming you're using an FLVPlayback component named "theVideo", here's some code for your first video frame:

stop(); // stop the timeline, so we can watch the video.
theVideo.contentPath = "bending.flv"; // tell the FLVPlayback component what video to load

var myListener:Object = new Object(); // create an event listener
myListener.complete = function(evt:Object) { // create a function to handle the "complete" status
	play();
}
theVideo.addEventListener("complete", myListener); // assign the listener to the FLVPlayback component
theVideo.play(); // play the video

When the video ends, the "complete" status will be broadcast. The event listener will then 'hear' that status, and run the function defined to react to it. In this case, it simply tells the timeline to play, which would lead to the next frame. On that next frame, you could use the exact same code, but replace "bending.flv" with "lifting.flv".

You will then have a timeline that will play a video, play another video, and then continue on down the timeline. .. There are more appropriate ways to write this code, but this should give you a a good starting point to work from.

Now, if you're wanting to do this in AS3, then I don't know. I have not worked with video in AS3 yet, so I am unsure as to what has changed. I will need to tackle it tonight though, for a project I'm working on. So, if you can wait until tomorrow, then I can give you an AS3 sample to work with. Unless, of course, somebody else would like to chime in and save me some time tonight. :D

Was This Post Helpful? 1

#4 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Two videos in one swf - how?

Posted 08 June 2007 - 04:29 PM

If all goes as planned, I'll have that AS3 version for you by morning. :^:
Was This Post Helpful? 0
  • +
  • -

#5 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Two videos in one swf - how?

Posted 09 June 2007 - 03:47 PM

AS3 version

frame 1:
import fl.video.VideoEvent; // needed to listen for video events
stop();

function myListener(evt:VideoEvent) {
	play();
}
theVideo.addEventListener(VideoEvent.COMPLETE, myListener); // "COMPLETE" must be capitalized
theVideo.source = "bending.flv"; // use "source" instead of "contentPath"
theVideo.play();

frame 2:
stop();
theVideo.source = "lifting.flv";
theVideo.play();


The included comments mention changes from the AS2 version. And I should probably mention that this does require the video files to be present. If you can't guarantee the files will be available to the SWF at runtime, then you'll want to implement some error handling. Perhaps a simple try/catch:

import fl.video.VideoError;
try {
	theVideo.source = "lifting.flv";
	theVideo.play();
} catch(err:VideoError) {
	// response to error;
}

This post has been edited by DilutedImage: 09 June 2007 - 03:49 PM

Was This Post Helpful? 0
  • +
  • -

#6 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 14
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Two videos in one swf - how?

Posted 10 June 2007 - 12:42 AM

The COMPLETE event may not work right. It seems that the Flash Video Encoder embeds incorrect meta data, causing the COMPLETE event to not properly detect the end of a video. .. So, I've devised a workaround: VideoEvent.COMPLETE Workaround - AS3
Was This Post Helpful? 0
  • +
  • -

#7 stephenz  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 12
  • Joined: 26-February 09

Re: Two videos in one swf - how?

Posted 26 February 2009 - 01:21 AM

Now that you have a SWF, you can make it as a flash video player to control the playback of the two FLV files. Also, you can make a playlist and add the flv to the playlist to control the play order of the flv files.
You can check these two tutorials below, the first tutorial will be a little complicated, and the second one is much more simple -

1. How Do I... Create a custom Web user interface for my Flash video?

2. How to make a flash video player for your website to control the playback of FLV files
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1