简体   繁体   English

如何创建自定义HTML5视频控件?

[英]How can I create custom HTML5 video controls?

I'm interested in building a custom video player in HTML5. 我有兴趣在HTML5中构建自定义视频播放器。 I have no problem embedding html5 video media utilizing the dual format of Ogg and h.264. 使用Ogg和h.264的双重格式嵌入html5视频媒体没有问题。 My main issue is in referencing the API for the video tag element. 我的主要问题是引用视频标记元素的API。 What properties and event listeners do I have access to via javascript? 我可以通过javascript访问哪些属性和事件监听器?

For a basic UI all you need is play pause and volume. 对于基本UI,您只需要播放暂停和音量。

HTMLVideoElement = document.getElementById("myvideo");
HTMLVideoElement.play();
HTMLVideoElement.pause();
HTMLVideoElement.volume = 1; /* values 0 to 1 */

These are nice 这些都很好

duration = HTMLVideoElement.duration;
currentTime = HTMLVideoElement.currentTime;

This will print out the complete list, but go beyond the HTML5 documented API with caution. 这将打印出完整列表,但要小心超出HTML5记录的API。

<video id="myvideo">
<source id="vidsource">
</video>
<script>
var HTMLVideoElement = document.getElementById("myvideo");
for (var key in HTMLVideoElement) { 
    document.write("<li>"+ key + ": " + HTMLVideoElement[key]);
} 
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM