Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the playback time in video

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to set the playback time in video. The editor thinks it is very practical, so I hope you can get something after reading this article. Let's take a look at it with the editor.

1. The shareVideoLink below the common attributes of video tag is the video connection address.

2. Obtain the video playback time. Initialize this method in mounted. When the video starts to play, you can get the real-time time of video playback.

/ * obtain video playback duration * / getVideoTime () {if (document.getElementById ('videoPlayer')) {let videoPlayer = document.getElementById (' videoPlayer'); videoPlayer.addEventListener ('timeupdate', function () {console.log (`current time point is ${videoPlayer.currentTime}, video length is ${videoPlayer.duration}`);}, false)}}

3. Set the video to start playing from a specific point in time. The parameter num in the following method indicates when to start playing the video. For example, click a button to perform the following method:

For example, if 2460198 is returned as milliseconds at the backend, you only need to convert it to seconds. Video will automatically calculate from seconds and assign a value to video label seconds. 2460198 is 246.0198 seconds (s). When we call the following method, we can write this:

This.playBySeconds (2460198amp1000) or this.playBySeconds (2460.198), because 2460.198 seconds is 41.0033001 minutes, so the video will automatically start playing from 41.0033001 minutes, so OK

/ / set the playback point and resume playBySeconds (num) {if (num & & document.getElementById ('videoPlayer')) {let myVideo = document.getElementById (' videoPlayer'); myVideo.play (); myVideo.currentTime = num;}}

Summary of other attributes of video:

Pause to turn on sound

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report