使用jQuery访问HTML 5视频进度事件 [英] Accessing HTML 5 Video Progress Event with jQuery

查看:723
本文介绍了使用jQuery访问HTML 5视频进度事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容适用于HTML5视频播放器活动。



我的合作伙伴和我在这个问题的当天很大一部分时间都很难过,希望有人可以就这个问题提供一些见解。我们已经能够使用普通的js访问进度事件,如下所示,但是当试图通过jQuery访问它时,我们在控制台中得到了未定义。

  // JS  - 像魅力一样工作
document.addEventListener(DOMContentLoaded ,init,false);
函数init(){
var v = document.getElementById('test-vid');
console.log(v)
v.addEventListener('progress',progress,false);
}
函数进度(e){
console.log(e.lengthComputable +''+ e.total +''+ e.loaded);
}


// jQuery - NO BUENO - 未定义在控制台中呈现
var vid = $('#test-vid');
$(vid).bind(progress,function(e){
console.log(e.total +''+ e.loaded +''+ e.lengthComputable);

});

在此先感谢,



JN

解决方案

为什么不直接使用:

  console.log(e.total +''+ e.loaded +''+ e.lengthComputable ); 
});

这应该可行,jQuery应该绑定事件

请看看这里



HTML5< video>回调?


The below is for an HTML5 video player event.

My partner and I have been stumped for a very large portion of the day on this issue and hope someone can lend some insight on the issue. We have been able to access the progress event with plain js as seen below but when trying to access this with jQuery we get undefined in console. Any help/ recommendations are greatly appreciated.

    //JS - Works like a charm
document.addEventListener("DOMContentLoaded", init, false);
function init() {
    var v = document.getElementById('test-vid');
    console.log(v)
    v.addEventListener('progress', progress, false);
}
function progress(e) {
    console.log(e.lengthComputable + ' ' + e.total + ' ' + e.loaded);
}


    //  jQuery - NO BUENO - Undefined rendered in console
    var vid = $('#test-vid');
    $(vid).bind("progress", function(e){
            console.log(e.total + ' ' + e.loaded + ' ' + e.lengthComputable );

            });

Thanks in advance,

JN

解决方案

Why not just use:

    $('video#test-vid').bind("progress",function(e){
        console.log(e.total + ' ' + e.loaded + ' ' + e.lengthComputable );
    });

This should work, jQuery should bind the events

Take a look here

HTML5 <video> callbacks?

这篇关于使用jQuery访问HTML 5视频进度事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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