Trouble Adding Music

I have been working on my game, “Slay the Dragon King (or Not),” and I have some public domain gaming music that I would like to add into my game. I tried using both the url format and the file from the computer format. I am using the “*sound link” and “sound filename.ogg” methods. I have tried both .flac and .ogg formats of the song. When I compiled the game and looked at the webpage to see why it wouldn’t play (by pressing F12), I get these two error messages: “unreachable code after return statement[Learn More] [music.html:3715:2](file:///C:/…/music.html)” and “NotSupportedError: The media resource indicated by the src attribute or assigned media provider object was not suitable.” The music.html is the file for the game for testing music purposes.

Can anyone help me figure this out?

1 Like

From the error msg, I think it’s because .flac and .ogg isn’t supported by CS. On the other hand, the wiki says that the format depends on your browser being able to play it.

For the file’s directory method (filename.ogg), have you tried to double check the exact name’s capitalization, adding the file’s directory (/mygame/filename.ogg), and so forth?


I have tried both. The site that you link, which is where I got my information, states that Tested with Chrome, using OGG, MP3, and WAV file formats, though what audio formats can be played may rely on what browser and system the player is using. I used the software’s in-program system to play the game to test it. I tested it in Ice Dragon, which is a Firefox-based browser, and I tried it in Chrome. It just isn’t working. I tried with .flac, .ogg, .wav, and .mp3 (which the game says they can’t play due to proprietary restrictions, but I still compiled it and tried playing it in the browser, but it still won’t work.

I even used both options of using the entire destination address, and the shortened version for being in the same folder.

I had a similar issue once, and learnt that Windows hides the .ogg and .wav directories by default, so my file couldn’t be found since it was “song.mp3.mp3” instead of “song.mp3”. I hope that helps at all

Oh, you mean “extension”? It could be, though I doubt it’s the case here. I’ll try to see this myself once I get back.

1 Like

Quick question: How long is the music duration?
IIRC, I tried using a fairly lengthy one and CS denies it. I had to cut it down into somewhere 30s ish until the script started willing to play it. CS also denies whitespace in the file’s name, fwiw.

1 Like

I cut the song into smaller clips–less than 30 seconds each; however it still won’t work. I tried ensuring I did both routes of extensions: having the file name as song_1 and song_1.wav since the song is in the same file directory as the game folder. I also had it as C:/documents/music, but that didn’t work either.