< video> .currentTIme不想设置 [英] <video>.currentTIme doesn't want to be set

查看:89
本文介绍了< video> .currentTIme不想设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一段Javascript,该Javascript可按一定的时间间隔在两个视频之间切换(不要问).更糟糕的是,每个视频都必须在特定的位置开始(大约十秒钟,然后再问一次).

I'm trying to write a piece of Javascript that switches between two videos at timed intervals (don't ask). To make matters worse, each video has to start at specific place (about ten seconds, and again, don't ask.)

通过使用YUI异步库触发间隔时间切换视频,我已经掌握了基础知识:

I got the basics working by just using the YUI Async library to fire to switch the videos at intervals:

YUI().use('async-queue', function (Y) {
                        // AsyncQueue is available and ready for use.

                        var cumulativeTime = 0;
                        var q = new Y.AsyncQueue()

                        for (var x = 0; x < settings.length; x++) {

                            cumulativeTime = cumulativeTime + (settings[x].step * 1000)

                            q.add( {

                                fn: runVideo,
                                args: settings[x].mainWindow,
                                timeout: cumulativeTime
                            })
                        }

                        q.run()
                    });

到目前为止,太好了.问题是我似乎无法在十秒内开始播放视频.

So far, so good. The problem is that I can't seem to get the video to start at ten seconds in.

我正在使用此代码来做到这一点:

I'm using this code to do it:

function runVideo(videoToPlay) {

    console.log('We are going to play -> ' + videoToPlay)

    var video = document.getElementById('mainWindow')
    video.src = '/video?id=' + videoToPlay

    video.addEventListener('loadedmetadata', function() {

        this.currentTime = 10 // <-- Offending line!
        this.play();

    })
}

问题是 this.currentTime 拒绝保留我设置的任何值.我正在通过Chrome运行该文件(该文件由Google App Engine实例后面的Google Storage提供),并且当调试器经过该行时,该值始终为零.

The problem is that this.currentTime refuses to hold any value I set it to. I'm running it through Chrome (the file is served from Google Storage behind a Google App Engine Instance) and when the debugger goes past the line, the value is always zero.

要设置此值,我缺少一些技巧吗?

Is there some trick I'm missing in order to set this value?

谢谢.

推荐答案

尝试使用Apache服务器.

Try use Apache server.

setCurrentTime无法在某些简单服务器上使用.

setCurrentTime not working with some simple server.

ex)服务器内置的python,服务器内置的php

ex) python built in server, php built in server

HTTP服务器应为支持部分内容响应". (HTTP状态206)

HTTP server should be Support partial content response. (HTTP Status 206)

这篇关于&lt; video&gt; .currentTIme不想设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆