youtube embeded player: change video link with javascript, dinamically
- by Anthony Koval'
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.