youtube embeded player: change video link with javascript, dinamically
Posted
by Anthony Koval'
on Stack Overflow
See other posts from Stack Overflow
or by Anthony Koval'
Published on 2010-04-12T14:18:28Z
Indexed on
2010/04/12
14:22 UTC
Read the original article
Hit count: 341
here is a part of html code (video urls marked with a django-template language variables):
<div class="mainPlayer">
<object width="580" height="326">
<param name="movie" value="{{main_video.video_url}}"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="{{main_video.video_url}}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="580" height="326"></embed>
</object>
</div>
and JS-code (using jQuery 1.4.x)
$(document).ready(function(){ .....
$(".activeMovie img").live("click", function(){
video_url = ($(this).parent().find('input').val());
$('.mainPlayer').find('param:eq(0)').val(video_url);
$('.mainPlayer').find('embed').attr('src', video_url);
})
...
})
such a algorithm works fine in ff 3.6.3, but any luck in chrome4 or opera 10.x., src
and value
are changed, but youtube player still shows an old video.
© Stack Overflow or respective owner