timeupdate事件函数不更新变量

时间:2019-01-14 20:14:58

标签: javascript jquery google-chrome-extension

我想进行视频循环。我有两个时间输入#from和#to。 第一次运行脚本时,它可以工作,但是如果我更改输入中的值,则timeupdate事件不会更新变量。

但是如果我更改输入值并输入比前一个数字少的数字,它将起作用。 您能告诉我这段代码有什么问题吗?还是还有其他方法?

对不起,我的英语说得不好。

P.S。 chrome调试器显示正确的值。

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
    var from, to;
    switch (request.todo) {
        case 'loopVideo':
        from = request.from.split(':');
        from = +from[0] * 60 + +from[1];

        to = request.to.split(':');
        to = +to[0] * 60 + +to[1];
        console.log(from, to);
        console.log(request.from, request.to);
        $('video').get(0).addEventListener('timeupdate', () => {
            if ($('video').get(0).currentTime >= to) {
                $('video').get(0).currentTime = from;
                console.log(from, to);
                console.log(request.from, request.to);
            }
        });
    break;
    }
});

0 个答案:

没有答案