Audio

The Audio object interface exposes properties, methods and events that can be used to program audio software and sound related programs using JavaScript.

var audio = new Audio();

 

audio.src = "file_name.mp3";

 

audio.play();

 

Properties

readonly = can be read but not changed

 

currentTime – Floating Point Number

 

startTime – Floating Point Number (readonly)

 

duration – Floating Point Number (readonly)

 

paused – Boolean (readonly)

 

defaultPlaybackRate – Floating Point Number

 

playbackRate – Floating Point Number

 

played – TimeRanges Object (readonly)

 

seekable – TimeRanges Object (readonly)

 

ended – Boolean (readonly)

 

autoplay – Boolean

 

loop – Boolean

 

controls – Boolean

 

volume – Floating Point Number

 

muted – Boolean

 

error – Media Error (readonly)

 

seeking – Boolean (readonly)

 

src – String

 

currentSrc – String (readonly)

 

preload – String – enumerated value

 

buffered – TimeRanges Object (readonly)

 

networkState – 0-3 (readonly) 0 – NETWORK_EMPTY 1 – NETWORK_IDLE 2 – NETWORK_LOADING 3 – NETWORK_NO_SOURCE

 

readyState – 0-4 (readonly) 0 – HAVE_NOTHING 1 – HAVE_METADATA 2 – HAVE_CURRENT_DATA 3 – HAVE_FUTURE_DATA 4 – HAVE_ENOUGH_DATA

Methods

play – Make the media object play or resume after pausing.

 

pause – Pause the media object.

 

load – Reload the media object.

 

canPlayType – Determine if a media type can be played.

Events

 

 

 

UA = user agent = browser software

 

loadstart – Fires when UA begins looking for media data.

 

progress – Fires while UA downloads media data.

 

suspend – Fires when media data download is suspended.

 

abort – Fires when media data download is aborted.

 

error – Fires when an error occurs while downloading media data.

 

emptied – Fires when a media object networkState is switched to 0.

 

stalled – Fires when media download stalls.

 

play – Fires when playback begins.

 

pause – Fires when playback is paused.

 

loadedmetadata – Fires when duration and dimensions of media can be accessed.

 

loadeddata – Fires when the UA has enough media data to begin playback.

 

waiting – Fires when playback stops due to unavailable media data(UA waiting for more data).

 

playing – Fires when playback starts.

 

canplay – Fires when UA determines the media can play, but further buffering may occur.

 

canplaythrough – Fires when UA determines the media can play without further buffering.

 

seeking – Fires when seek operations occur. The seeking property changes to true.

 

seeked – Fires when the seeking property changes to false.

 

timeupdate – Fires when the playback position changes.

 

ended – Fires when the media has ended.

 

ratechange – Fires when the playbackRate property changes.

 

durationchange – Fires when the duration property changes.

 

volumechange – Fires when either the volume or muted properties change.

 

Audio Element

There is also an HTML <audio> element that creates an audio object that you may script against.

renewdev

I Am Developer And Want To Share My Knowledge With The World..:) ;) . I Have Another Social Networking Website (Renewchat) And For Designing Or Developing Of Website Purpose You Can Contact Me On Renew Coder .. :) ;)

Leave a Reply

Your email address will not be published. Required fields are marked *