最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I create custom HTML5 video controls? - Stack Overflow

programmeradmin1浏览0评论

I'm interested in building a custom video player in HTML5. I have no problem embedding html5 video media utilizing the dual format of Ogg and h.264. My main issue is in referencing the API for the video tag element. What properties and event listeners do I have access to via javascript?

I'm interested in building a custom video player in HTML5. I have no problem embedding html5 video media utilizing the dual format of Ogg and h.264. My main issue is in referencing the API for the video tag element. What properties and event listeners do I have access to via javascript?

Share Improve this question asked Feb 17, 2010 at 14:09 Jim JeffersJim Jeffers 18k4 gold badges43 silver badges52 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

For a basic UI all you need is play pause and volume.

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 plete list, but go beyond the HTML5 documented API with caution.

<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>
发布评论

评论列表(0)

  1. 暂无评论