Home › Forums › JavaScript › How can I refresh the youtube flash video player with javascript?
- This topic is empty.
-
AuthorPosts
-
October 10, 2010 at 6:12 pm #30509mattvotMember
WARNING: For some reason, even though I’ve wrapped the code in the pre->code tags, it still implements the flash
Hi,
I’m struggling to find a way to refresh a flash instance with javascript.
I am setting up a playlist type effect with the help of jQuery to replace the object settings with new ones.
In firefox it works fine, but in all other browsers no luck.
Here is part of the jQuery:
$('.current_youtube_video').parent().find('li.youtube_video').each(function(i)
{
//console.log($(this).attr('id'));
var li_id = $(this).attr('id');
$(this).click(function(){
//alert($(this).attr('id'));
$(this).parent().parent().find('object param[name=movie]').val('http://www.you-tube.com/v/' + li_id);
$(this).parent().parent().find('object embed').attr('src', 'http://www.you-tube.com/v/' + li_id);
$(this).parent().parent().find('.current_title').attr('href', 'http://www.you-tube.com/watch?v=' + li_id);
$(this).parent().parent().find('.current_title').html( $(this).find('.youtube_link').html() );
$(this).parent().parent().find('.current_youtube_video').show();
$(this).parent().parent().find('.current_youtube_video').removeClass('current_youtube_video');
$(this).addClass('current_youtube_video');
$(this).hide();
});
});
And here is an example of the HTML
Any ideas? Thanks
October 11, 2010 at 10:47 am #78339Chris CoyierKeymasterI think the rendering of the post above was messed up specialically because the links were to youtube.com. Seems like forums are tying to be helpful and turn links to youtube URL’s in to playable youtube videos. I fixed it by turning the URL’s to you-tube.com
As far as refreshing the flash, I’d literally remove the object/embed and replace it entirely rather than trying to replace certain attributes of existing elements.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.