JW Player 可以让多个玩家一起玩吗?
尝试用JW Player实现多个播放器。我尝试了几种方法并查看了文档,但我不太确定为什么代码会被破坏。
代码片段如下所示:
In head:
<script type='text/javascript' src='/jwplayer/jwplayer.js'></script>
JS:
$('video').jwplayer({
flashplayer: '/jwplayer/player.swf',
controlbar: 'none',
stretching: 'fill',
height: 120,
width: 120
});
HTML:
<video id="video" src="/media/original/original-video.mp4">Loading Video ...</video>
我收到的错误是:
$("video").jwplayer is not a function
现在我认为这是意味着 jwplayer.js 文件没有被加载。然后我读到可能是因为速记 $ 没有被拾取,所以我尝试了 jQuery。没有一个起作用。然而,当我更改 JavaScript 以便它播放单个视频时,例如:
jwplayer('video').setup({
flashplayer: '/jwplayer/player.swf',
controlbar: 'none',
stretching: 'fill',
height: 120,
width: 120
});
代码实际上有效。然而,这要求我的所有视频标签都具有相同的 ID。我不能这样做,因为我想要多个玩家。
任何帮助将不胜感激。如果有例子就更好了!感谢您的阅读。
Trying to implement multiple players with JW Player. ive tried a few ways and looked at the docs but im not quite sure why the code is breaking.
Code snippets shown below:
In head:
<script type='text/javascript' src='/jwplayer/jwplayer.js'></script>
JS:
$('video').jwplayer({
flashplayer: '/jwplayer/player.swf',
controlbar: 'none',
stretching: 'fill',
height: 120,
width: 120
});
HTML:
<video id="video" src="/media/original/original-video.mp4">Loading Video ...</video>
The error I receive is:
$("video").jwplayer is not a function
Now i thought this meant the jwplayer.js file was not being loaded. then i read maybe its because the shorthand $ is not being picked up so i tried jQuery. None worked. However when I change the javascript so that it plays a SINGLE video eg:
jwplayer('video').setup({
flashplayer: '/jwplayer/player.swf',
controlbar: 'none',
stretching: 'fill',
height: 120,
width: 120
});
The code actually works. However this requires all my video tags to have the same ID. Which I cant do as i want multiple players.
Any help would be really appreciated. An example would be even better! Thanks for reading.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案。这很简单!只需添加 jQueryeach() 以便每个标签都被初始化:)
希望这对其他人有帮助:
i found the answer. It was a simple one to! just had to add in a jQuery each() so that every tag was initialized :)
Hope this helps someone else: