My JS Code:
$('body').append('<div id="mediaplayer"></div>');
$.getScript('js/mplayer/jwplayer.js', function ()
{
jwplayer("mediaplayer").setup({
flashplayer: "js/mplayer/player.swf",
file: ''+v_url+'',
autostart: "true"
});
$('#mediaplayer_wrapper').css('z-index','107').css('width','853px').css('height','505px').css('padding','10px').addClass('bg_one').center();
});
I close the player with:
$('#mediaplayer, #mediaplayer_wrapper').remove();
but when i load the player again (with开发者_如何学JAVA an other url) ... the player did not start. If there maybe an unload function?
I got it
jwplayer('mediaplayer').remove();
The jwplayer(...).remove() is a function from the jwplayer api - this is not jquery.
remove() - Being the reverse of the setup() call, this call will remove a JW Player from the page. It ensures the player stops playback, the DOM is re-set to its original state and all event listeners and timers are cleaned up.
So you have to call your jwplayer(...).setup(...) again after removing it. This remove() has nothing to do with a jquery-remove. detach is not a jwplayer function.
try with jQuery.detach instead of remove
, it is cleary written on document
The .detach() method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.
$('#mediaplayer, #mediaplayer_wrapper').detach();
Hopefully it works :)
精彩评论