my web hosting doesn't allow uploading mp3, so I can't upload the audio files to my site. I tried using other sites to host audio but then the audio couldn't load, with the console saying "XMLHttpRequest cannot load [url]. No 'Access-Control-Allow-Origin' header..."
now I understand why this is happening, I just want to ask is there any way for me to make this work? Cuz without audio, the visual novel would be very boring.
Hi aister,
welcome to the forums! Your question doesn't really have much to do with the engine, but I'll try to answer it anyway.
The error you are encountering is a "security feature" of browsers. That said, you could read up on Cross-Origin Resource Sharing (CORS) to allow cross-domain requests initiated from within a script (the audio library (Howler.js) used by WebStory Engine in this case, I assume). The mentioned 'Access-Control-Allow-Origin' header is part of this technology, but (afaik) you will have to be able to send customized HTTP headers on your host for this to work and some older browsers (IE < 10) may not support this feature at all.
What kind of hosting do you use, by the way? Not allowing MP3s seems like a rather crippling thing for a hoster that's meant to be used for modern web applications. Wouldn't it be better to look for an alternative?
(05-21-2016, 07:06 PM)jfhs Wrote: [ -> ]Hi aister,
welcome to the forums! Your question doesn't really have much to do with the engine, but I'll try to answer it anyway.
The error you are encountering is a "security feature" of browsers. That said, you could read up on Cross-Origin Resource Sharing (CORS) to allow cross-domain requests initiated from within a script (the audio library (Howler.js) used by WebStory Engine in this case, I assume). The mentioned 'Access-Control-Allow-Origin' header is part of this technology, but (afaik) you will have to be able to send customized HTTP headers on your host for this to work and some older browsers (IE < 10) may not support this feature at all.
What kind of hosting do you use, by the way? Not allowing MP3s seems like a rather crippling thing for a hoster that's meant to be used for modern web applications. Wouldn't it be better to look for an alternative?
hi jfhs, thanks for the response
I understand the error and why that is happening. But unfortunately I won't be able to use another alternative.
I guess a little bit of explanation would be proper here. My website is a "social network"-ish where users can create their own visual novels without actually having their own website. I did a little bit of editing to the index.html (renamed to index.php) and have it take the user's data stored in the database instead of game.xml. So yeah, the problem is not that I can't host mp3, it's I can't allow them, the users, to upload mp3, as it will be a big burden to the server (as well as risk of having copyrighted music on my website)
what I'm looking for right now, is a way for me to tweak the engine's javascript file to change the way it loads audio (and in the future, video) so that it would rely on the audio's canplaythrough instead of ajax loading.
Hi aister,
I just checked loading audio files in a WSE game cross-domain. It works with the appropriate headers, e.g. GitHub sends those headers for raw files if you want to test it. I kinda understand your dilemma, but I can't change how audio works in the engine internals just for that - the engine is using Howler.js for all audio and given how cumbersome audio in browsers still can be I'm rather glad we have it.
Of course you are free to tweak the engine to your liking, but you should be aware that this will prevent you from updating to newer versions in the future if you don't put in the time to apply your tweaks time and again. Also, if you change the audio part to use plain HTML5 audio, you might encounter all of the silly little browser issues with HTML5 audio that libraries like Howler try to manage for you.
I found there's an option to use only HTML5 audio, not the Web Audio API in Howler:
https://github.com/goldfire/howler.js/tr...lean-false
You could try whether that solves your problem. If it does, I'll think about making some of Howler's API available in the WebStory XML format.
update, for some reason, the game still returns the access control error, however the mp3 still loads and plays like it should have. There are no audio element created so I'm guessing it's running with web audio api. Honestly I don't know what is happening. I guess if it's running, it's fine, but still I would love to find out what causes the error to prevent any problems in the future.
http://moesocial.com/vn/?url=http%3A%2F%...2FN5E5gyMy this is the website in case you wanna take a look. The pastebin is the xml file, and the mp3 is hosted on picosong.