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 use the property buffered that returns the TimeRanges object in html5

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use the property buffered that returns the TimeRanges object in html5. I hope you will get something after reading this article. Let's discuss it together.

Example

Get the first buffer range (part) of the video in seconds:

MyVid=document.getElementById ("video1"); alert ("Start:" + myVid.buffered.start (0) + "End:" + myVid.buffered.end (0))

Definition and usage

The buffered property returns the TimeRanges object.

The TimeRanges object represents the audio and video buffer range of the user.

Buffer range refers to the time range of buffered audio and video. If users jump and play in audio and video, they will get multiple buffer ranges.

Browser support

All major browsers support the buffered attribute.

Note: this property is not supported by Internet Explorer 8 or earlier browsers.

Grammar

Audio | video.buffered value describes the TimeRanges object

Represents the buffered part of audio and video.

TimeRanges object properties:

Length-get the number of buffered ranges in audio and video

Start (index)-gets the start position of a buffered range

End (index)-gets the end position of a buffered range

Note: the following table for the first buffer range is 0.

Example 1: buffered in audio

Audio's cache has only one segment, starting at 0 and ending at timeRange.end (0)

Var myAudio = document.getElementById ('myAudio'); myAudio.preload = true; myAudio.autoplay = true; myAudio.src ='.. / content/audio/ wide sea and sky .mp3'; myAudio.onplay = function () {console.info ("start playback");} myAudio.oncanplay = function () {console.info ('enter playable state'); console.info ('total length:' + myAudio.duration) } / / load status monitoring myAudio.ontimeupdate = function (e) {/ * * Audio cache has only one segment, starting at 0 and ending at timeRange.end (0) * / / console.info (myAudio.buffered); / / console.info (myAudio.buffered.length) / / console.info ('start:'+myAudio.buffered.start (0) +', end:'+myAudio.buffered.end (0)); var timeRange = myAudio.buffered; console.info (timeRange); console.info ('start:'+ timeRange.start (0) +', end:'+ timeRange.end (0)) } after reading this article, I believe you have a certain understanding of "how to use the property buffered of the returned TimeRanges object in html5". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

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

Development

Wechat

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

12
Report