我最终解决了这个问题
$oVideo.bind('timeupdate', function() {
var currVideo = document.getElementById("vPlayer");
//console.log(video.attr('id'));
var iNow = currVideo.currentTime;
//console.log(iNow);
var countdown = eval(currVideo.duration - iNow);
// countdown = countdown /3600;
$('.decr-time').html('-' + rectime(countdown));
if (!bTimeSlide) {
$oTimeSlider.slider('value', iNow);
}
});
嘿,我想提前感谢任何人。
我需要为 HTML5 视频创建倒数计时器。这是我能够拼凑起来的。我真的很感谢任何可以帮助我解决这个问题的人。我的控制台没有显示倒计时错误;但我的倒计时似乎不起作用。
//count down
$oVideo.bind('duration', function() {
var countdown = $oVideo.duration - $oVideo.currentTime;
$down.text(rectime(countdown));
if (! bTimeSlide)
$oTimeSlider.slider('value', countdown);
});
这是javaScript的一个片段
var $oMain = $(this);
var $oVideo = $('video', $oMain);
var $oTimeSlider = $('.time_slider', $oMain);
var $oTimer = $('.timer', $oMain);
var $down = ('.decr-time', $oMain);
var bTimeSlide = false;
//count up
$oVideo.bind('timeupdate', function() {
var iNow = $oVideo[0].currentTime;
$oTimer.text(rectime(iNow));
if (! bTimeSlide)
$oTimeSlider.slider('value', iNow);
});
///count down
$oVideo.bind('duration', function() {
var countdown = $oVideo.duration - $oVideo.currentTime;
$down.text(rectime(countdown));
if (! bTimeSlide)
$oTimeSlider.slider('value', countdown);
});
HTML
<section class="content-wrapper">
<div class="video_player">
<video controls>
<source src="../assets/video.mp4" type="video/mp4" />
<source src="../assets/video.webm" type="video/webm" />
<source src="../assets/video.ogv" type="video/ogg" />
</video>
<div class="custom_controls">
<a href="index.html" title="Back" class="back-button"></a>
<a class="play" title="Play"></a>
<a class="pause" title="Pause"></a>
<div class="timer">00:00</div>
<div class="time_slider"></div>
<div class="decr-time">-00:00</div>
</div>
</div>
</section>