HTML5 -- audio

Definition and Usage

<audio> 标签定义声音,比如音乐或其他音频流。

Browser support

Internet Explorer 9+, Firefox, Opera, Chrome and Safari support

Properties of the Audio object

Attributes describe
audio.volume (read/write) volume
audio.src (read/write) song address
audio.currentTime (read/write) The current elapsed time of the song
audio.duration (read) the total length of the song
audio.paused (read) Whether the boolean type is in a paused state
audio.ended (read) boolean whether the song has finished playing

Methods of the Audio object

method describe
audio.volume (read/write) volume
audio.play() start the song
audio.pause() make the song start to pause
audio.load() Reload audio element
audio.getStartDate() Returns a new Date object representing the current timeline offset
audio.canPlayType() Check if the browser can play the specified audio type
audio.fastSeek() Specify playback time in audio player

Audio object events

event describe
audio.oncanplay = fn() call fn when the song is downloaded
audio.onvolumechange = fn() fn is called when audio.volume is transformed
audio.onplay = fn() call fn after the song starts playing
audio.onpause = fn() call fn after the song is paused
audio.ontimeupdate = fn() The song will always call fn during playback
audio.onended = fn() call fn after a song has finished playing

to be continued……

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324404360&siteId=291194637