Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embedded Flash Video File - You Tube style control

Status
Not open for further replies.

jpcooling

Technical User
Sep 8, 2006
7
0
0
GB
I am trying to create an embedded video in Flash that DOESN'T start streaming on open (Like You Tube). This is so I can out more than one video on the same page without both trying to buffer. I also want the video (which is currently set up 'false' on autostart) to display a random scene from the movie. At them moment..because it is paused on start..it just displays the first frame (which is black). How do I solve these problems. Any ideas?
 
But if you do that doesn't it go badly out of sync?
 
If it's long yes it will be out of synch. If you want to avoid that then you have to use external FLV. But the entire length of the video needs to be loaded into the memory first in order to display random frame - you can't display the frame which is not yet downloaded! (Unless it's come from Flash Media Server.)

Kenneth Kawamoto
 
Ok well it is a very long clip (one hour)
So forget the random preview. How do I stop the video buffering on open? I would like it to only buffer when play is pressed and to stop when pause is pressed. Like youtube.
The reason for this is that on another page I will have four vids. If they all stream on open that will cause a big problem.
 
You may have to create a custom video player like Youtube. Initially display a static image taken from your video on start up, then fire NetStream.play() only when the play button is pressed, etc.

Kenneth Kawamoto
 
Is there any info on how to fire up NetStream.play?
 
I'm out of my league here. Sorry for bothering you.
 
It might seem a little complicated but its really not that bad. We'll start with just playing a video back without the playback component..
Try this,
go to your library: hit the little 'bulleted list' icon in the top right corner and choose 'new video'
a video symbol will appear in your library, drag this to your main stage and give it an instance name of 'video' (properties panel)
now create a new layer called 'actions', hit the first frame and fire up the actions panel:
Copy the following into the actions panel:
Code:
nc = new NetConnection(); //create new net connection
nc.connect(null);
ns = new NetStream(my_nc); //creates new netstream
ns.setBufferTime(6); // sets the download buffer
video.attachVideo(ns); // attaches netstream to video object
ns.play(thefile);// attaches the flv to the netstream

Now we'll go through each line:
line 1: creates a netconnection object which, when used in conjunction with the netstream, enables us to stream an FLV over HTTP protocol
line 2: ignore for now (not relevant for what we're doing at this stage)
line 3: creates the netstream to stream the FLV over HTTP
line 4: sets the playback buffer to '6' seconds so that the FLV won't intiate playback until 6 seconds of video have already been downloaded (this helps prevent the video playback exceeding the amount already downloaded)
line 7: attaches the netstream (carrying the FLV) to the video object on the stage that we created earlier
line 8: points the netstream to the location of the FLV, '(thefile)' should be replaced with the url to your FLV i.e. '
Cool.. that's it, try testing the movie. After a short period while the video buffers, you should see it pop up on the stage.

I'll leave it there for now so if you want further advice on how to take this further, let me know
smiletiniest.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top