逐帧加载视频 [英] Load video Frame by Frame

查看:147
本文介绍了逐帧加载视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在页面加载时自动在html5视频标签中设置海报。这就是为什么我在这里使用jquery:

I want to set a poster in html5 video tag automatically while page is loading. Thus why, I am using a jquery here:

<script>
            $(document).ready(function(){
                var vid = $('#v0')[0];

                vid.onplay = vid.onclick = function() {
                    vid.onplay = vid.onclick = null;

                    setTimeout(function() {
                        vid.pause();
                        setInterval(function() {
                            if ($.browser.opera) {
                                var oldHandler = vid.onplay;
                                vid.onplay = function() {
                                    vid.pause();
                                    vid.onplay = oldHandler;
                                };
                                vid.play();
                            } else {
                                vid.currentTime += (1 / 29.97);
                            }
                        }, 2000);
                    }, 12000);

                    setInterval(function() {
                        $('#time').html((vid.currentTime * 29.97).toPrecision(5));
                    }, 100);
                };
            });
            
        </script>



我的HTML就在这里:


And in my HTML is here:

<body>
        <p id="time"></p>
        <video id="v0" controls tabindex="0" autobuffer preload>
        <p>Sorry, your browser does not support the <video> element.</p>
        </video>
</body>



但是,当我运行我的项目时,视频标签中的皮肤是黑色的,并且皮肤中没有视频的第一帧。我想,我的jquery不在这里工作。你有没有解决这个问题的建议?

谢谢。


But, when I am running my project, there skin is black in video tag and there is no first frame of the video in the skin. I think, my jquery is not working here. Have you any suggesstion to solve this problem?
Thank you.

推荐答案

document ).ready( function (){
var vid =
(document).ready(function(){ var vid =


' #v0')[ 0 ];

vid.onplay = vid.onclick = function (){
vid.onplay = vid.onclick = null ;

setTimeout( function (){
vid.pause();
setInterval( function (){
if
('#v0')[0]; vid.onplay = vid.onclick = function() { vid.onplay = vid.onclick = null; setTimeout(function() { vid.pause(); setInterval(function() { if (


.browser.opera){
var oldHandler = vid.onplay;
vid.onplay = function (){
vid.pause();
vid.onplay = oldHandler;
};
vid.play();
} else {
vid.currentTime + =( 1 / 29 97 );
}
}, 2000 );
}, 12000 );

setInterval( function (){
.browser.opera) { var oldHandler = vid.onplay; vid.onplay = function() { vid.pause(); vid.onplay = oldHandler; }; vid.play(); } else { vid.currentTime += (1 / 29.97); } }, 2000); }, 12000); setInterval(function() {


这篇关于逐帧加载视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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