Get the App
SLTechnology News&Howtos  ›  Development  › 

Share HTML5 video event application examples

Shulou Source: shulou.com Published: 2022-06-02 17:10:48 10月25日 Update

This article focuses on "sharing HTML5 video event application examples". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "sharing HTML5 video event application examples"!

Use the onloadedmetadata event to obtain the duration of the video, and use the ontimeupdate event to obtain the progress of the current video playback. The sample code is as follows:

1. Obtain the video time length

After the video is loaded into video, use the onloadedmetadata event to get the length of time for the video.

The code is as follows:

Video.onloadedmetadata = function () {

Var vLength = video.duration

Console.log (vLength)

}

2. Progress of the current video playback

When the video starts to play, you can use the ontimeupdate event to get the progress of the current video playback. The ontimeupdate event is triggered when the currentTime property of the video object changes. The currentTime property is a floating-point decimal place that can be fetched to a decimal place of 12 places.

The code is as follows:

Video.ontimeupdate = function () {

Var vTime = video.currentTime

Console.log (vTime)

}

At this point, I believe you have a deeper understanding of "sharing HTML5 video event application examples". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Events videos examples applications code time progress length digits content decimals attributes learning practicality deeper interest practicality objects simple operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei Docker Linux NVidia