felix
New Member
Posts: 4
Posts: 4
|
Post by felix on Aug 20, 2015 19:36:16 GMT
Hi,
I have problems to load an audio file with Master Audio by script on runtime. I try:
Audio_q.GetComponent<SoundGroupVariation>().internetFileUrl = www_audio_uri; Audio_q.GetComponent<SoundGroupVariation>().LoadInternetFile(); Audio_q is my public Game Object pointing to the one group clip that I want to change. www_audio_uri is the www address of my file as a string, e.g. "http://somewhere.com/audiofile.ogg"
I got this error:
No Audio Sources found to add Internet File '[here the url to my audio file that is definitively correct!!!]' to. UnityEngine.Debug:LogError(Object) DarkTonic.MasterAudio.MasterAudio:LogError(String) (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:4993) DarkTonic.MasterAudio.<PopulateSourceWithInternetFile>c__IteratorF:MoveNext() (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/AudioResourceOptimizer.cs:223) If I put my audio URL before starting the game, everything works fine.
What am I doing wrong?
Best Felix
T
|
|
|
Post by DarkTonic Dev on Aug 20, 2015 20:24:38 GMT
You cannot change the Url at runtime, because a map of which URLs map to which audio sources has already been set up during the Awake event. It likely is already trying to download the file from the Url you specified in the Inspector as well. If you change the Url at runtime, the new Url is not in the map so it fails to populate after loading. So URLs must be hard-coded only.
|
|
felix
New Member
Posts: 4
Posts: 4
|
Post by felix on Aug 20, 2015 20:41:36 GMT
Ok, thank you for your really fast reply. But what do you think would be the most efficient way to load audio files from internet and put it into master audio on runtime?
|
|
|
Post by DarkTonic Dev on Aug 20, 2015 22:18:32 GMT
There's only 1 way, which is to set up the URLs in advance and not try to change the URLs at runtime. It does load the files no problem like that. The example scene has a working example.
|
|