Question about the ontimeupdate event of the HTML5 Video Object

Source: Internet
Author: User

A Video playback page has been created recently. The HTML5 Video object is used. This is a new object in HTML5. It supports online playback of videos in different formats and has powerful functions, in addition, many events are extended, and video playback can be controlled through JavaScript scripts. Refer to the following two links:

Http://msdn.microsoft.com/en-us/library/windows/apps/hh465962.aspx

Http://www.w3school.com.cn/html5/tag_video.asp

You can useOntimeupdateEvent to report the current playback progress. You can also use this event to control other elements on the page based on the video playback status, for example, you can switch chapters and display additional information as the video playback progresses. The following is an example:

                                            Time: 0 of 0 seconds.                          

Of course, you can also dynamically add attributes or upload events to the Video object like using other elements on the page, such:

video.ontimeupdate = function () { getCurrentVideoPosition(); };

However, the above line of code seems to be invalid on Chrome. You can useAddEventListenerTo replace it:

videoPlayer.addEventListener("timeupdate", function () { getCurrentVideoPosition(); }, false);

I don't know why Chrome cannot directlyOntimeupdateThe event is mounted on the Video element, but must passAddEventListenerMethod to add events. HoweverAddEventListenerIt is also compatible with IE and Firefox browsers, so it should be passed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.