Peter
Peter

Reputation: 11825

JW-Player - How to unload?

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 an other url) ... the player did not start. If there maybe an unload function?

Upvotes: 2

Views: 9071

Answers (3)

micele
micele

Reputation: 31

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.

Upvotes: 3

Peter
Peter

Reputation: 11825

I got it

jwplayer('mediaplayer').remove();

Upvotes: 7

xkeshav
xkeshav

Reputation: 54016

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 :)

Upvotes: 2

Related Questions