HTML5视频时长不播放视频 [英] HTML5 Video duration without playing video
问题描述
我想在HTML5中播放视频时长,不用播放视频,或者在您在视频管或其他视频网站上看到的视频缩略图上播放视频。
<
对于HTML5,一旦加载了文件的元数据,就应该可以使用视频标记的duration属性。请参阅这个答案,了解如何做到这一点:
引用Mikushi的anwser:
myVideoPlayer.addEventListener('loadedmetadata',function(){
console.log(videoPlayer.duration);
});
通过侦听'loadedmetadata'事件,您将确保持续时间值已加载。
有关loadedmetadata的更多详细信息,请访问: http:// www。 w3schools.com/tags/av_event_loadedmetadata.asp
I am trying to get video duration in HTML5 with out playing video or before playing video to show on video thumb as you seen on you tube or any other video sites.
Any help will be really appreciate.
Thanks in Advance.
For HTML5 you should be able to use the video tag's duration property, once the file's metadata is loaded. See this answer for a good way to do it:
Problem retrieving HTML5 video duration
To quote the anwser by Mikushi:
myVideoPlayer.addEventListener('loadedmetadata', function() {
console.log(videoPlayer.duration);
});
By listening for the 'loadedmetadata' event you will ensure the duration value has been loaded.
More details on the loadedmetadata can be found here: http://www.w3schools.com/tags/av_event_loadedmetadata.asp
这篇关于HTML5视频时长不播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!