HTML5视频时长不播放视频 [英] HTML5 Video duration without playing video

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

问题描述

我想在HTML5中播放视频时长,不用播放视频,或者在您在视频管或其他视频网站上看到的视频缩略图上播放视频。


解决方案



<

对于HTML5,一旦加载了文件的元数据,就应该可以使用视频标记的duration属性。请参阅这个答案,了解如何做到这一点:



检索HTML5视频时长问题



引用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屋!

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