Earlier we learned the most basic usage of audio and video. In order to control the playback of audio and video more flexibly, we need to learn the related properties, methods and events provided by HTML5.
Audio and video related properties
Properties |
Description |
##src | The URL address used to specify the media resource |
autoplay | Auto play after the resource is loaded |
buffered | Used to return a TimeRanges object to confirm that the browser has cached the media file. |
controls | Provides control bars for playback |
currentSrc | Returns the URL of media data Address |
currentTime | Get or set the current playback position in seconds |
defaultPlaybackRate | Return the default playback speed |
duration | Get the duration of the current media |
loop | Set or Return whether to loop playback |
muted | Set or return whether to mute |
networkState | Return to audio video Current network status |
paused | Check if the video is paused |
playbackRate | Set or return audio The current playback speed of the video |
played | Returns a TimeRanges object. TimeRanges represents the audio and video range that the user has played |
preload | Set or return whether to automatically load audio and video resources |
readyState | Return the current readiness status of audio and video |
seekable | Return the TimeRanges object, indicating that the current media resource can be requested |
seeking | Returns whether data is being requested |
valume | Set or return the volume, the value is 0 to 1.0 |
Audio and video related methods
Method | Description |
canPlayType() | Detect whether the browser can play the specified audio and video |
load() | Reload Audio and video elements |
pause() | Stop the currently playing audio and video |
play() | Start playing the current audio and video |
Audio and video related events
##Event | Description |
canplay | This event occurs when the browser can start playing the specified audio and video |
canplaythrough | When the browser expects to be able to play the specified audio and video without stopping This event occurs when the specified audio and video continues to be played while buffering |
durationchange | This event occurs when the duration data of audio and video changes |
loadeddata | This event occurs when the current frame data has been loaded, but there is not enough data to play the next frame of the specified audio video |
loadedmatadata | This event occurs when the metadata for the specified audio video has been loaded. Metadata includes duration, dimensions (video only), and text track |
loadstart | This event occurs when the browser starts looking for the specified audio video |
progress | This event occurs while downloading the specified audio video |
abort | When the audio video terminates loading , this event occurs |
ended | After the audio and video playback is completed, this event occurs |
error | This event occurs when audio and video loading errors |
pause | This event occurs when audio and video are paused |
play | This event occurs when playback starts |
playing | This event is triggered when it is paused due to buffering or is ready after stopping |
ratechange | This event occurs when the audio and video playback speed changes |
seeked | The user has moved or jumped This event occurs when reaching a new position in the audio video |
seeking | This event occurs when the user starts to move or jump to a new audio and video playback position |
stalled | This event is triggered when the browser attempts to obtain media data, but the data is not available |
suspend | This event is triggered when the browser deliberately does not load media data |
timeupdate | This event is triggered when the playback position changes |
volumechange | This event is triggered when the volume changes |
waiting | This event is triggered when the video stops due to buffering |
[Related recommendations]1. Detailed explanation of the video tag test application of html5
2. Using video elements in html5 Make a video player
3. Share the problem and solution of a video tag that cannot play mp4
4. H5 video tag can only Solution to playback of sound but not video
5. Solution to IIS MIME not registering the MP4 type, resulting in the inability to recognize the vidoe tag
The above is the detailed content of Detailed introduction to HTML5 multimedia audio and video (2). For more information, please follow other related articles on the PHP Chinese website!