【问题标题】:Disable Seek on vimeo player在 vimeo 播放器上禁用搜索
【发布时间】:2017-08-11 06:13:03
【问题描述】:

我需要在 vimeo 嵌入式播放器上禁用搜索功能。似乎唯一的答案是在寻找的事件上使用 setCurrentTime 。问题是它会陷入无限循环。可能是因为 timeupdate 也会在搜索时触发。

this.player.on('timeupdate', this.vimeoPlayProgress.bind(this));
this.player.on('seeked', this.vimeoSeek.bind(this));

然后在 vimeoSeek 中:

var player = this.player;
var playTime = this.vimeoPlayTime;
player.setCurrentTime(playTime).then(function (seconds) {
                ...

            });

【问题讨论】:

  • 有什么解决办法吗?我也有同样的问题。
  • 没有。与 vimeo 客户支持交谈,他们说这是不可能的。唯一的解决方法是使用 vimeo 托管视频的直接链接并制作您自己的播放器。

标签: javascript vimeo


【解决方案1】:

我尝试如下,但在缓冲时间出现问题,如下所述:https://github.com/vimeo/player.js/issues/61

    var player = new Vimeo.Player(iframe);
    var priorTimeUpdateTime = 0;

    player.on('seeked', function() {
        player.pause().then(function() {
            player.getCurrentTime().then(function(seconds) {
                //console.log('seconds: '+ seconds + ' priorTimeUpdateTime: ' + priorTimeUpdateTime);  
                if (seconds > priorTimeUpdateTime) {
                    player.setCurrentTime(priorTimeUpdateTime).then(function(seconds) {

                        // seconds = the actual time that the player seeked to

                    }).catch(function(error) {
                        switch (error.name) {
                            case 'RangeError':
                                // the time was less than 0 or greater than the video’s duration     
                                break;
                            default:
                                // some other error occurred
                                break;
                        }
                    });
                }
            }).catch(function(error) {
                // an error occurred
                console.log('Vimeo API error');
            });
        });
        player.play();
    });

    player.on('ended', function() {
        alert('Do something at the end!');
    });

    setInterval(function() {
        player.getCurrentTime().then(function(seconds2) {
            priorTimeUpdateTime = seconds2;
            //console.log('Playhead Update: ' + priorTimeUpdateTime);
        }).catch(function(error) {
            // an error occurred
            console.log('Vimeo API error');
        });
    }, 15000)

【讨论】:

  • 今年早些时候,Vimeo 添加了一个seeking getter,有没有人成功地使用它来禁用视频中的向前搜索?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-02
相关资源
最近更新 更多