在定义之外使用 requirejs 实例?
我正在使用 requirejs 来确定依赖关系。 我有一些代码确定 Video.js 的使用:
require.config({
'paths': {
'bc': 'https://players.brightcove.net/1507807800001/default_default/index.min'
},
waitSeconds: 30
});
require(['bc'], function() {
var myPlayer = videojs.getPlayers().myPlayerID;
myPlayer.on('loadstart', function(){
myPlayer.play();
})
});
我还有一些代码想要获取实例并使用该 Video.js:
if (typeof myPlayer != "undefined") {
console.log("myPlayer existence true");
myPlayer.stop();
} else {
console.log("myPlayer existence false");
}
有没有办法访问 Video.js 定义之外的内容? 这是一个工作示例 https://playcode.io/868784/
I am using requirejs to determine dependencies.
I have some code that determines the use of the Video.js:
require.config({
'paths': {
'bc': 'https://players.brightcove.net/1507807800001/default_default/index.min'
},
waitSeconds: 30
});
require(['bc'], function() {
var myPlayer = videojs.getPlayers().myPlayerID;
myPlayer.on('loadstart', function(){
myPlayer.play();
})
});
Also I have some code that wants to get an instance and use that Video.js:
if (typeof myPlayer != "undefined") {
console.log("myPlayer existence true");
myPlayer.stop();
} else {
console.log("myPlayer existence false");
}
Is there a way to access outside of the Video.js's definition?
This is a working example https://playcode.io/868784/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以定义您的模块并稍后使用它:
Video.js:
You can define your module and later use it:
Video.js: