【问题标题】:Google VRView for Web - Detect when a 360° video finishesGoogle VRView for Web - 检测 360° 视频何时结束
【发布时间】:2017-05-29 08:15:09
【问题描述】:
我的要求非常简单:我需要在当前正在运行的视频结束后立即使用 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
});
});
【问题讨论】:
标签:
video
html5-video
google-vr
webvr
360-degrees
【解决方案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;
}
}