Callback function for video.js?

妖精的绣舞 提交于 2021-01-28 19:00:11

问题


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 callback function I can use after my ajax has finished loading in the html?

To be specific I'm after the actual function name (if there is one) that video.js has made. ie the javascript which runs to dress up the videos.


回答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.




回答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.



来源:https://stackoverflow.com/questions/16483808/callback-function-for-video-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!