过去几天我对 Vimeo 的提示点事件没有任何问题,一切正常,我今天才开始注意到它。
这是一个简单的提示点触发器。
当视频的当前时间到达提示点时,它会执行某些操作,在下面的示例代码中,我们将仅使用 alert 输出一些内容。
在 google chrome 控制台上使用 firebug,它说提示点已成功添加,但是当视频到达提示点时,它会引发错误。
控制台截图:https://user-images.githubusercontent.com/42766598/45663523-898c3f80-bb39-11e8-8d87-4a4be84a3483.png

测试页网址: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 端的一个错误,此后已解决:ojita

关于javascript - Vimeo 播放器 API 提示点事件 : Uncaught TypeError: Time must be a number,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52379162/

10-09 00:53