PlaySound: Difference between revisions
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
The files need to be included in the project by adding them to the Project Explorer. | The files need to be included in the project by adding them to the Project Explorer. | ||
PlaySound returns a reference to the sound. You can use this reference to control the sound. | |||
PlaySound is supported starting with iOS Safari 6 and Chrome 31, so it will work on all current and recent iOS and Android devices. It is not supported in the Android browser or Internet Explorer. Since PhoneGap uses the Android browser, it will not work with PhoneGap. | PlaySound is supported starting with iOS Safari 6 and Chrome 31, so it will work on all current and recent iOS and Android devices. It is not supported in the Android browser or Internet Explorer. Since PhoneGap uses the Android browser, it will not work with PhoneGap. | ||
== Properties and Methods == | |||
{| class="wikitable" | |||
|- | |||
| soundRef.start() || Start playing the sound. PlaySound auto plays, so this is not normally needed. | |||
|- | |||
| soundRef.stop() || Stop playing the sound | |||
|- | |||
| soundRef.loop || Make the sound loop endlessly | |||
|} | |||
== Example (Basic) == | == Example (Basic) == |
Revision as of 10:47, 29 September 2014
PlaySound filename
Description
PlaySound plays .mp3 and .wav sound files. Playback is immediate, with no on screen controls, making it excellent for user interactions and gaming.
The files need to be included in the project by adding them to the Project Explorer.
PlaySound returns a reference to the sound. You can use this reference to control the sound.
PlaySound is supported starting with iOS Safari 6 and Chrome 31, so it will work on all current and recent iOS and Android devices. It is not supported in the Android browser or Internet Explorer. Since PhoneGap uses the Android browser, it will not work with PhoneGap.
Properties and Methods
soundRef.start() | Start playing the sound. PlaySound auto plays, so this is not normally needed. |
soundRef.stop() | Stop playing the sound |
soundRef.loop | Make the sound loop endlessly |
Example (Basic)
PlaySound "BellToll.wav"
Example (JavaScript)
NSB.PlaySound("BellToll.wav");
Output
(sound of a bell tolling)