We help IT Professionals succeed at work.

dynamically change embedded google video in javascript

ICPooreman
ICPooreman asked
on
1,792 Views
Last Modified: 2010-08-05
So I'm embedding google video on my site.  However I want to have navigation on the page that changes what video is displayed to the user and I want it to be done dynamically.
So here is how google tells me to embed a video on my page
<embed id="myVideo" style="width:100%;height:500px;" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-563808319704458028&hl=en" flashvars="&subtitle=on"> </embed>
                        
(note I added the id myself)
and what I want to do is when a link is clicked change the src of the embedded video so that when you hit play it plays the new video.  Preferably I'd also like to change the image being cast on the video to that of the new video.
<a href="#" onclick="changeVideo('http://video.google.com/videoplay?docid=-2004785759717366066&hl=en')">Colbert</a>  
      
where changeVideo is a javascript function somewhere that takes in the new src.
function changeVideo(videoURL){
      document.embeds['myVideo'].src = videoURL;      
}

I've tried a lot of different things but I can't find anything that will work... does anybody have any ideas?
 
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
to test it type this:

http://video.google.com/googleplayer.swf?docId=-563808319704458028&hl=en

in the text box and click "Load Movie"

Author

Commented:
Ok thanks for that...

I'm testing it now... at first glance there appears to be something wrong with it.  It loads fine the one video I had embedded on my page before.  But if I attempt it with the URL of a video I've never viewed before it just takes me to a blank white screen.

Let me keep looking at it though.
there's a problem with the url you posted, not the code...

to prove this just hard code the url... it doesn't work:

<embed id="myVideo" style="width:100%;height:500px;" type="application/x-shockwave-flash" src="http://video.google.com/videoplay?docid=-2004785759717366066&hl=en" flashvars="&subtitle=on"> </embed>

Author

Commented:
wait I figured it out why it wasn't working for me... for the other videos I was just grabbing the link from the top of the page which is different from the embed URL... Thanks alot this really is great.
you're welcome

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.