简体   繁体   English

在html5视频的确切帧上显示html元素

[英]Displaying html element on exact frame in html5 video

I'd like to display some html text over a playing html5 video. 我想在播放的html5视频上显示一些html文本。

The video will feature an empty sign, and i'd like to place some custom text over the video, so that it appears to be displayed on the sign. 该视频将带有一个空符号,我想在视频上放置一些自定义文本,以使其看起来显示在该符号上。

How can I best sync the showing of the html element with a specific frame in a video? 如何最好地将html元素的显示与视频中的特定帧同步?

Preferably on the exact frame, so the sync would be perfect. 最好是在精确的帧上,这样同步才是完美的。

You could get the time-frame being played in the player. 您可以在播放器中获得播放的时间范围。

HTML: HTML:

<video
    id="videoPlayer"
    controls="controls">
    <source src="video.mp4" type="video/mp4">
</video>

JQuery: jQuery的:

$(document).ready(function(){
  $("#videoPlayer").on(
    "timeupdate", 
    function(event){
      showHTMLElement(this.currentTime, this.duration);
    });
});

You could round-off the currentTime as per your need to compare in showHTMLElement(). 您可以根据需要在showHTMLElement()中四舍五入currentTime。

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

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