2017-05-29 54 views
1

我的要求非常簡單:我需要在當前運行視頻結束後立即使用Google VRView for Web加載另一個360°視頻。Google VRView for Web - 當360°視頻結束時檢測到

documentation中描述了4種類型的事件,但不幸的是沒有事件檢測視頻結束。我什至不能找到一個屬性來禁用循環。

有沒有人能夠實現這樣的事情?

var vrView = new VRView.Player('#vrview', { 
 
    video: 'link/to/first-video.mp4', 
 
    is_stereo: true 
 
    }); 
 

 

 
// I couldn't find an event like this or another solution 
 

 
vrView.on('end', function() { 
 

 
    vrView.setContent({ 
 
    video: 'link/to/second-video.mp4', 
 
    is_stereo: true 
 
    }); 
 

 
});

回答

1

雖然文檔顯示4種類型的事件,就像你說的,在GitHub上源似乎真正支持和附加一個「結束」(https://github.com/googlevr/vrview)。

你可以看到它在main.js定義和player.js使用:

Player.prototype.onMessage_ = function(event) { 
    var message = event.data; 
    if (!message || !message.type) { 
    console.warn('Received message with no type.'); 
    return; 
    } 
    var type = message.type.toLowerCase(); 
    var data = message.data; 

    switch (type) { 
    case 'ready': 
    case 'modechange': 
    case 'error': 
    case 'click': 
    case 'ended': 
     if (type === 'ready') { 
     if (data !== undefined) { 
      this.duration = data.duration; 
    } 
     }