From NSB App Studio
Revision as of 14:14, 4 September 2023 by Ghenne (talk | contribs) (→‎Description)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

PlaySound filename[,volume]


PlaySound plays .mp3 and .wav sound files. Playback is immediate, with no on screen controls, making it excellent for user interactions and gaming.

volume is optional. It's value is from 0 to 1. The default is 1.

The files need to be included in the project by adding them to the Project Explorer. This can be done dragging them from the Finder into the Project Explorer panel. Filenames should not have spaces in them.

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.

Here's a good site with lots of free sound files:

Properties and Methods

soundRef.start(0) Start playing the sound. PlaySound auto plays, so this is not normally needed.
soundRef.stop(0) Stop playing the sound.
soundRef.loop Make the sound loop endlessly



// Make sound loop
  bell = NSB.PlaySound("BellToll.wav");

// Stop playing sound

  PlaySound "BellToll.wav"

' Make sound loop
  bell = PlaySound("BellToll.wav")

'Stop playing sound


(sound of a bell tolling)