Narrat Docs
Search…
Playing Audio

Config

The play function plays audio, either music or sounds.
To use the play function, the game needs to have audio files loaded by adding them to the config file:
1
"audio": {
2
"musicName": {
3
"loop": true,
4
"src": "music/myMusic.mp3"
5
},
6
"soundName": {
7
"src": "sounds/mySound.mp3"
8
}
9
}
Copied!
The audio engine used is Howler. Options added in the config of an audio file will also be passed to Howler. Refer to the Howler docs for possible options.

Playing music or sounds

Once there are audio files loaded in the engine, audio can be played with the play function at any time in the script:
play music musicName
Playing with mode music will replace stop and replace the current music to play a new one. There is only one music playing at a time
play sound soundName
Playing with the mode sound will just play a sound, no matter what else is already playing.

Stopping and pausing

It is also possible to pause or stop sounds or music:
stop music (no need to specify the name because there is only one music playing
stop sound soundName (name must be specified)
For example, one could do a dramatic pause of the music
1
play music suspense
2
wait 1500
3
pause music
4
play sound scary
5
wait 100
6
talk character idle "Suddenly, something happened!"
7
play music # resume the music
Copied!