Vimeo Player API 提示点事件:未捕获类型错误:时间必须是数字



在过去的几天里,我对Vimeo的cuepoint事件没有任何问题,一切正常,我今天才开始注意到它。

这是一个简单的提示点触发器。

当视频的当前时间达到提示点时,它会做一些事情,在下面的示例代码中,我们将使用 alert 输出一些东西。

在谷歌浏览器控制台上使用Firebug,它说cuePoint已成功添加,但是当视频到达cuepoint时,它会抛出错误。

控制台截图:https://user-images.githubusercontent.com/42766598/45663523-898c3f80-bb39-11e8-8d87-4a4be84a3483.png

提示点添加成功,编号: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

相关内容

最新更新