我在 videoJS 之上构建了一个播放器,但在访问 videoJS .ready()
内的公共(public)函数时遇到了问题。问题是我的代码似乎可以在除 IE 之外的任何地方运行(在 chrome、safari、ff 等中运行):
var myPlayer = _V_('myvideojsId');
myPlayer.ready(function() {
var player = this;
player.myPublicFunction = function() {
alert("hey!");
}
});
myPlayer.myPublicFunction();
在 IE 中我得到
Object does not support this property or method
在 myPlayer.myPublicFunction()
行上。是其他浏览器允许我编写错误的代码还是这个 IE 的错?
任何帮助都会很棒,谢谢!
克里斯
最佳答案
引用他们的文档,它准确地显示了 Jonathan 所说的内容: https://github.com/zencoder/video-js/blob/master/docs/api.md#wait-until-the-player-is-ready
顺便说一句,他对 IE 的看法是正确的。尽管我们对它又爱又恨,但它多次为我发现了真正的问题。
为了更快地引用,这里有一个替代方法来完成此操作:
_V_("example_video_1").ready(function(){
var myPlayer = this;
// EXAMPLE: Start playing the video.
myPlayer.play();
});
关于javascript - videojs公共(public)方法访问就绪函数和IE之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13727143/