首页 > 解决方案 > Vimeo Player API 提示点事件:未捕获类型错误:时间必须是数字

问题描述

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

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

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

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

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

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

标签: javascripttimevimeo

解决方案


这是 Vimeo 端的一个错误,此后已被解决:https ://github.com/vimeo/player.js/issues/318#issuecomment-422447186


推荐阅读