VideoJS - unable to destroy and initialize

Atadj picture Atadj · Feb 11, 2013 · Viewed 20.1k times · Source

On VideoJS website you state that support was moved to StackOverflow, so let's try it here. I've got the following code:

var player = _V_('the_id', {}, function(){
    jQuery('.remove').on('click.destroyvideojs', function(){
        player.destroy();
        jQuery(this).unbind('click.destroyvideojs');
    });
});

It initializes video at first and it destroys it.

But when I want to initialize it again using the same exact piece of code, it doesn't work. It doesn't initialize the script on the same element ID (when it was removed from DOM and added again with correct initialization call after it's been added). I'm wondering why this might be happening?

Another try today:

var the_id = 'my_id';
var player = _V_(the_id, {}, function(){        
    player.destroy();
    _V_(the_id, {}, function(){
        alert('reinit');
    });
});

So, re-initialization of VideoJS simply doesn't work. Furthermore, it removed controls from the video now.

Answer

manafire picture manafire · Jun 10, 2013

In case this helps anyone, it looks like it's dispose in Version 4:

var player = videojs('my-video');
player.dispose();