如何以00:25/00:30显示视频当前和持续时间?

时间:2016-05-19 11:36:19

标签: jquery html5 html5-video

我想以不同的格式显示视频currentTimeduration

现在显示它的方式是:

0:9 / 0:33

我想让它像这样显示:

00:09 / 00:33

或视频持续时间超过1分钟

03:10 / 12:27

我现在拥有的当前代码

    video.on('timeupdate', function() {

        // Set to minute and seconds
        var time = video[0].currentTime;
        var minutes = Math.floor(time / 60);   
        var seconds = Math.floor(time);

        // Set the current play value
        currentTimer.text(minutes + ':' + seconds);
    });

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

        // Set to minute and seconds
        var time = video[0].duration;
        var minutes = Math.floor(time / 60);   
        var seconds = Math.floor(time);  

        // Set the video duration
        durationTimer.text(minutes + ':' + seconds);
    });

2 个答案:

答案 0 :(得分:2)

此代码应该按您的要求执行:



- find: paths=DIRECTORY file_type=directory patterns="*.log"
  register: dir_files

- shell: mv *.log /tmp
  when: dir_files.matched|int != 0




答案 1 :(得分:0)

</body>
<script>
	var myVideoPlayer = document.getElementById('video-element'),
	meta = document.getElementById('meta');
	
	myVideoPlayer.addEventListener('loadedmetadata', function () {
	var duration = myVideoPlayer.duration;
	meta.innerHTML = "Duration is " + duration.toFixed(2) + " seconds."
	});
</script>
<div class="col-md-12">
		    	<div class="col-md-8" id='player'>
					<video style="width:100%;height:auto;"  id='video-element' controls preload controlsList="nodownload"> <source src="../videos/SampleVideo_1280x720_5mb.mp4" id="s1" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> <source src="../videos/sample1.ogg" type='video/ogg; codecs="theora, vorbis"'> </video>
				</div>
				<div class="col-md-4">
					<div class="box-body">
						<hr style="margin: 28px 0px 10px;">
						<div class="col-md-12">
							<video width="168" height="94"  id='cc'> <source src="../videos/SampleVideo_1280x720_5mb.mp4" id="s1" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> 
								<source src="../videos/sample1.ogg" type='video/ogg; codecs="theora, vorbis"'> 
							</video>
						</div>
					</div>
				</div>
				<div id="meta"></div>
			</div>