enyo.Sound

enyo.Sound is a component that allows you to play sound effects or other audio resources. This component is an abstraction of HTML 5 Audio.

Initialize a sound component as follows:

{kind: "Sound", src: "http://mydomain.com/media/myfile.mp3"}

To play a sound, do this:

this.$.sound.play();

You can get a reference to the actual HTML 5 Audio object via this.$.sound.audio.

Published Properties

Name Default Description
src "" URL of the audio resource. May be a path relative to the application's index.html file.
preload true If true, the audio resource is loaded when the control is created. This trades an increase in network/memory usage for a decrease in latency.
audioClass null (webOS only) Sound channel through which to play audio. The default channel is "defaultapp", which is used for application sounds. Use "media" for playback of music.

Methods

play()

Begins (or, if paused, resumes) playback of the audio resource. If the sound is already playing, playback restarts at the beginning.

The play method takes no arguments and nothing is returned.