View Full Version : Having only one youtube player, but load other videos?

03-07-2007, 03:04 AM
I wanted to embed some youtube videos on my site. I can get it to where I can have the videos to play in their own player. What I want to do is display one player and have links. When the link is pressed, load that youtube video into the player. Can this be done via JavaScript or php? Thanx

03-07-2007, 03:11 AM
Javascript, must like a rollover image.

Basically, you would just replace the src of the video, or just switch out the divs.

however, this is not a great idea in that you would need to reload the video each time.

A better idea would be to have say 3 div elements, each with a video, and each set to hidden, except the one selected. Then use the javascript to switch the visibility of the one desired and turn the rest off.

However, one possible issue here is sound and that the sound would likely continue from any hidden yet invisible movies.

03-07-2007, 05:50 AM
I thought about that, using layers. Okay here is something.
Here is the sample code for a youtube video.

<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/pfLjLo3mclg"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/pfLjLo3mclg" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

Only thing that would change in the next video is the src url. Couldn't we write something that would dynamically change the url when a link is pressed.

03-07-2007, 06:58 AM
Flash is tricky. Using flash to display video is a little different than other flash applications like menus and what are called 'movies'. I've been playing with a flash version of a video and have found that the only sure fire way to get rid of it is to have it in an iframe and change the src of the iframe.

That is what I would suggest here. Have an iframe on your page. Target it by name with links to pages, each containing one of the various flash videos.

Trying to get them all on one page as a sort of effort at preloading may seem like a good idea but, even short videos are pretty big files so you are better off just letting each one stream in turn.

Flash video (for the most part) is only for broadband anyway.

03-08-2007, 05:22 AM
It would be reliable but also force the video to reload each time.

I think looking at a different solution would make sense.

03-16-2007, 03:24 PM
What about something like Facebook.com's shared videos? I'm trying to achieve the same thing but their code is waaay too complicated for me to understand.