Load resources from external web site

Load resources from external web site
0.0 0

#1

Hello. I’m using cocos2d js for developing game and distribute it on mobile platforms (iOS/Android)
Is it possible somehow to get resources from external URLs being in runtime?
I mean this:
cc.audioEngine.playEffect("http://mywebsite.com/res/audio/sound.wav", false);
I know, this may look pointless and weird, but I really need it)
Would be appreciated for any workaround as well.


How to change the default preloader image in cocos2d-JS 3.0 RC2
#2

hiho

you’ll need to do something about cross origin resource sharing.

an easy solution is using http://cors.io/

http://cors.io/?http://www.yoururlhere.org

adding this will allow you to load data from external sites.

cheers


#3

is it critical for native apps too? (i mean cors)
the thing is that I tried to run the code above, I also tried to preload sounds via AudioEngine feature, but I can’t see the app is accessing web resources. I own the server, i have an access to web logs.

At the moment my goal is to understand whether it’s technically possible at all?


#4

OK, I’ve finally invented a workaround. Maybe it will be useful for someone, I’m gonna keep it here.
http://heximal.ru/blog/en/coding/cocos2d-js-zagruzit-vneshnie-audio-fajly-i-javascript-kod/


#5

I also need the ability to load audio from URLs (like in Unity). Calling cc.loader.loadRes with a URL isn’t enough – it does not work. Of course, I’d strongly prefer to not use an unsupported workaround for such critical functionality for our app.

Any idea if this is on the roadmap? @slackmoehrle ? Thanks! :slight_smile:


#6

Bump, we actually will need this within the next few weeks. Is this feature (load audio from web URL instead of file path) on your roadmap?


#7

Bump.

I was shocked to learn this can’t be done. We need the ability to load other external asset types from external sources (scenes, prefabs, animations) not just audio. @slackmoehrle, could you please comment if this is on the roadmap? Feels like really basic functionality to me.


#8

Sure. Let me find out.