Reputation: 115
I'm trying to load by AJAX a video working with VideoJS but I can't manage how to make it work after the AJAX load. I've been reading a lot about this but I couldn't find any solution.
I show you an example. You can check this link with a working video. And here I'm trying to load the previous link through an AJAX load.
This is the code I run after the AJAX call. You can check it also in the links I just entered.
_V_($('.video-container-large').find('.video-js')).ready(function(){
var myPlayer = this;
myPlayer.destroy();
myPlayer.play();
});
return false;
} );
Do you know why VideoJS is not initialized fine? I tried a lot of alternatives without any success, so any help will be much appreciated!
Thank you.
Upvotes: 0
Views: 5211
Reputation: 7821
The argument passed to _V_()
(or videojs()
) should be an element or an id, not a jquery object. Use array notation to get the element from the object.
videojs($('.video-container-large').find('.video-js')[0]).ready(function(){ …
Note: _V_()
was deprecated in video.js 4 and removed in video.js 5. Use videojs()
.
Upvotes: 3