I have this sound I want to add when the game starts, and when I do all I can it won't play, is there a way where you can start the game and have sound play without having to do anything first?
If it's an MP3, Quest is not compatible with .mp3 files. .aslx and other file types work.
You can set it to play in the game's start script.
...but whether the sound will play on its own or not depends on how the game is being played.
If it's being played in the Quest desktop player, the MP3 or WAV format will work when using Quest's default play sound
script. (You can use HTML to play other audio formats, though. I will provide a link to the documentation at the end of this post.)
If it's being played online, it gets more complicated (and much more frustrating):
controls
so the player actually has a 'Play' button to press.play sound
script, but we can only choose MP3 or WAV in that script.) On the other hand, most modern browsers will play .ogg files, but Internet Explorer and Edge will not. (I think Safari will play certain types of .ogg files, if you have the proper plugin, but I’m not certain.)To further frustrate Quest authors, they keep updating browsers, too!
About a year ago (give or take a month or few), I did some very extensive research on this. I added audio and video in every format I could use to a test game. Then, I thoroughly tested everything in all the different browsers on every type of device I could get my hands on: Windows PC, Android device, iPhone, and iPad.
I recently played the test game on one of the Android phones which I used to test things out the first time, and now things behave differently. A year ago, my phone's browser would only play .ogg audio, but now it will play .mp3 as well. This sucks because I added backup formats to my HTML audio elements. A year or so ago, any given browser would only play one format with that setup, but now some browsers will load BOTH formats -- which means it plays two identical sounds in a row when I have something like this:
s = "<audio autoplay>"
s = s + "<source src='" + GetFileURL("snd effect.ogg") + "' type='audio/ogg' >"
s = s + "<source src='" + GetFileURL("snd effect.mp3") + "' type='audio/mp3' >"
s = s + "Your browser does not support the audio tag.</audio>"
msg (s)
I also found that autoplay
now works on my Samsung Galaxy S5, but it still doesn't work on my Samsung Galaxy S7. (Frustrating!)
Do note that there is a little solace to be found with the Quest desktop player. Because its version of the Chromium browser hasn't been updated in years, it is consistent. We can play .mp3 and .wav formats with the play sound
script, and we can play .ogg and .wav files with HTML audio elements, but it won't load .mp3 files from HTML audio elements. Also, the author can always choose when a sound plays (with or without the player doing anything) in the Quest desktop player, whether we are using the play sound
script or an HTML audio element.
Also note that this is not Quest's fault at all. This is all about cross-platform (and cross-browser) compatibility. (In other words, it's all about money. The .mp3 and .mp4 formats are not open source.)
Most of the information here is still true today:
http://docs.textadventures.co.uk/quest/adding_sounds.html
The information concerning HTML audio elements is no longer completely accurate. Sometimes autoplay
works now on some mobile devices, and sometimes some browsers will play both sounds when an HTML audio element contains multiple format sources.
The information concerning Quest's default play sound
script should still be accurate, just for the record.
I advise anyone adding sound (or video) to make sure everything gets thoroughly tested in the Quest desktop player as well as every browser on every type of device every time you add a sound (or a video).
It sounds tiring, I know... But, as my dear old daddy used to say, "you gotta feed the monkey if you want to watch him poop."
Thank you for the information I will remember this, before I when and red this I figured it out. I didn't know that certain formats won't play on certain browsers or devices. My game is already published I could go back in and do more with the audio so it works on all but I not going to as it was a test run and a practice. I will be doing another for practice so I will be doing all that, adding in different formats for all the many different browsers and devices. Thank you for replying it really helped my understanding.