Jump to content

Error when adding sounds with phaser


DavidAames
 Share

Recommended Posts

Hey guys, 

first things first: sorry for my bad english. 
I have a big problem with phaser. 
I build a educational game without a webserver and everything's going fine and runs perfectly (using Phaser.CANVAS).
But when i load a sound (game.load.audio("theme","assets/music/theme.ogg");) i get this error:
"Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https."
I've watched online and it seems, i need to have a webserver. 
But there are some questions and problems with this kind of thing.

1. Why can i add pictures, animations,code and more from my harddrive but music is a no go?!

2. I want the Game runs complete offline. It's important because the guy i am making this game for is teacher and they still have no Internet in his school. (unbelivable but true)

3. If I would setup a local server, then every who gets the game need one to?!

it's so frustrating.

i build the game as a html-file because this game should go to other schools with linux, mac etc. 
I just wanted it runs everywhere. :( With or without internet, no matter what OS is using.
But what is a game without a Soundtrack? :(
I have build the whole game and the only thing missing, is sound.

I hope somebody can help me.

Link to comment
Share on other sites

1. Why can i add pictures, animations,code and more from my harddrive but music is a no go?!

Glad you got it working.

2. I want the Game runs complete offline. It's important because the guy i am making this game for is teacher and they still have no Internet in his school. (unbelivable but true)

If everything works from file protocol then having a folder full of assets isn't a bad way of sharing your app and letting the browser handle cross-platform concerns (although better ways exist, primarily just sharing a url, but I understand how that isn't an option in your case).

The other avenue you have is to create a proper deployable bundle. I think Cordova can do this for desktop OS's (although its normally used for mobile apps) but something like Electron or Node-Webkit is probably a better fit for you. Electron (for example) will create proper executables and you have other options for creating a downloader etc etc its a real app so the OS will treat it like one.

3. If I would setup a local server, then every who gets the game need one to?!

Yep, and this is a pain as they'll have to install the necessary dependencies to run that server or you'll have to build an executable for your target platform (this can be particularly tricky if you're targeting Windows). Most users won't have the skills (nor the desire) to do this, and some, such as a school laptop, possibly won't have the permissions to do so.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...