javascript - Vimeo Player API 提示点事件:未捕获类型错误:时间必须是数字
问题描述
在过去的几天里,我对 Vimeo 的 cuepoint 事件没有任何问题,一切正常,我今天才开始注意到它。
这是一个简单的提示点触发器。
当视频的当前时间到达提示点时,它会做一些事情,在下面的示例代码中,我们将使用 alert 输出一些内容。
在谷歌浏览器控制台上使用萤火虫,它说 cuePoint 已成功添加,但是当视频到达 cuepoint 时,它会引发错误。
提示点添加成功,id:10333313-0233-4312-8013-111233103010
未捕获的类型错误:时间必须是数字。
测试页网址:http ://rjlwebph.com/vimeo-cuepoint/test.html
下面是我的代码:
<html>
<head>
<script src="https://player.vimeo.com/api/player.js"></script>
</head>
<body>
<iframe src="https://player.vimeo.com/video/67449472?autoplay=1&title=0&byline=0&portrait=0" width="853" height="480" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
<script>
var iframe = document.querySelector('iframe');
var player = new Vimeo.Player(iframe);
var cueTime = 60;
player.addCuePoint( cueTime, {
customKey: 'customkey'
}).then(function(id) {
console.log('cue point added successfully, id: '+id);
}).catch(function(error) {
switch (error.name) {
case 'UnsupportedError':
console.log('cue points are not supported with the current player or browser: '+cueTime);
// cue points are not supported with the current player or browser
break;
case 'RangeError':
console.log('the time was less than 0 or greater than the video’s duration: '+cueTime);
// the time was less than 0 or greater than the video’s duration
break;
default:
console.log('some other error occurred: '+cueTime);
// some other error occurred
break;
}
});
player.on('cuepoint', function() {
alert('cuePoint reached... '+cueTime);
});
</script>
</body>
</html>
解决方案
这是 Vimeo 端的一个错误,此后已被解决:https ://github.com/vimeo/player.js/issues/318#issuecomment-422447186
推荐阅读
- python-3.x - 创建我自己的文本分类器 - 如何创建一个新列来检查是否键入文本并跨多行返回组
- linux - 如何修复 jpg 文件的“[:参数过多”
- javascript - “Window.onload”在 Node.js 中不起作用
- javascript - PhoneGap 不在移动设备上显示页面
- python - 几个小时后,Django 图像和内容消失了
- android - 如何解谜
values.xml 中的错误? - python - 将 argparse 与格式化的位置参数一起使用
- mongodb - 如何创建具有可变日期的部分索引?
- winforms - 循环没有完全显示所有元素
- python - 如何使用 environtment.yml 文件将带有 pip 的本地库安装到 conda 环境?