Skip to content Skip to sidebar Skip to footer

Callback Function For Video.js?

I'm using the video.js plugin. I'm using ajax to load in another bunch of videos from another page but I want to call the javascript again to perform the skinning again. Is there a

Solution 1:

Ajax has a success call back you may be able to use.

$.ajax({ 
    type: "GET",
    url: url,
    success: function(data){
         //Call back stuff
    }
});

There are also, error and other callbacks you can use. You can find information on here.

If you don't have access to the ajax event, you can still bind to the success call back. Here's documentation on how to do it.

Solution 2:

The best solution I found was here

(function(){
    var video = document.querySelector('video');
    var onDurationChange = function(){
        if(video.readyState){
            //to your thing
        }
    };

    video.addEventListener('durationchange', onDurationChange);
    onDurationChange();
})();

Trying to do

videojs("myplayer").ready(function() {
    console.log(this.duration()); //0
});

wouldn't work.

Post a Comment for "Callback Function For Video.js?"