Class enchant.DOMSound
Class to wrap audio elements. Safari, Chrome, Firefox, Opera, and IE all play MP3 files (Firefox and Opera play via Flash). WAVE files can be played on Safari, Chrome, Firefox, and Opera. When the browser is not compatible with the used codec the file will not play. Instances are created not via constructor but via enchant.DOMSound.load.
- Defined in: enchant.js
- Extends enchant.EventTarget
Constructor Attributes | Constructor Name and Description |
---|---|
Field Attributes | Field Name and Description |
---|---|
Current playback position (seconds).
|
|
Sound file duration (seconds).
|
|
Volume.
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
clone()
Create a copy of this Sound object.
|
|
<static> |
enchant.DOMSound.load(src, type, callback, onerror)
Loads an audio file and creates DOMSound object.
|
pause()
Pause playback.
|
|
play()
Begin playing.
|
|
stop()
Stop playing.
|
- Methods borrowed from class enchant.EventTarget:
- addEventListener
- clearEventListener
- dispatchEvent
- on
- removeEventListener
Class Detail
enchant.DOMSound()
Field Detail
{Number}
currentTime
Current playback position (seconds).
{Number}
duration
Sound file duration (seconds).
{Number}
volume
Volume. 0 (muted) ~ 1 (full volume).
Method Detail
-
{enchant.DOMSound} clone()Create a copy of this Sound object.
- Returns:
- {enchant.DOMSound} Copied Sound.
-
Loads an audio file and creates DOMSound object.
- Parameters:
- {String} src
- Path of the audio file to be loaded.
- {String} type Optional
- MIME Type of the audio file.
- {Function} callback Optional
- on load callback.
- {Function} onerror Optional
- on error callback.
- Returns:
- {enchant.DOMSound} DOMSound
-
pause()Pause playback.
-
play()Begin playing.
-
stop()Stop playing.