2017-03-20 53 views
2

vimeoの埋め込みプレーヤーでシークを無効にする必要があります。唯一の答えは、シークされたイベントに対してsetCurrentTimeを使用することです。問題は、それが無限ループに投げ込まれるということです。たぶん、timeupdateもシーク時にトリガされるからです。vimeoプレーヤーでシークする

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

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

      }); 
+0

これに対する解決策はありますか?私は同じ問題を抱えています。 – JackTheKnife

+0

ありません。 vimeoのカスタマーサポートに話しかけ、彼らはそれが不可能だと言った。回避策は、vimeoホストビデオへの直接リンクを使用して、独自のプレーヤーを作ることです。 – brianxautumn

答えて

0

私は以下のようにそれを試してみましたが、ここに述べたように、それに伴う問題は、バッファリング時間の間にあります: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) 
 

関連する問題