Vimeo Player API提示点事件:未捕获的TypeError:时间必须为数字

时间:2018-09-18 04:53:38

标签: javascript time vimeo

在过去的几天里,我对Vimeo的提示点事件没有任何问题,一切都很好,今天我才开始注意到它。

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

当视频的当前时间到达提示点时,它会执行某些操作,在下面的示例代码中,我们将使用警报输出一些内容。

在Google chrome控制台上使用firebug时,它表示成功添加了cuePoint,但是当视频到达该cuepoint时,它将引发错误。

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

  

提示点已成功添加,id:10333313-0233-4312-8013-111233103010

     

未捕获的TypeError:时间必须是数字。

测试页网址: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>

1 个答案:

答案 0 :(得分:0)

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