Question by 
               RaphaelVRosa · Oct 26, 2016 at 08:30 PM · 
                c#audiowwwfile  
              
 
              AudioSource not working. Empty Exception
I'm trying to load and play an wav file that exists in my Application.dataPath but when the game gets to this line _GoAudioSource.PlayOneShot(audioLoader.audioClip); It justs throws a empty exception and no sound is played.
I've already checked if the path is correct and it is. I've also tried uploading this wav file to an FTP and loading it via HTTP instead of File:/// but nothing changes.
This is my full code:
     private IEnumerator WriteResponseAudio(ResponseModel res)
         {
             File.WriteAllBytes(Path.Combine(Application.dataPath, FILENAME_RESPONSE), Convert.FromBase64String(res.intent.audio.content));
             string path = "file:///" + Application.dataPath + "/" + FILENAME_RESPONSE;
             WWW audioLoader = new WWW(path);
             yield return audioLoader;
             try
             {
                 _GoAudioSource.PlayOneShot(audioLoader.audioClip);
             } catch (Exception ex)
             {
                 Debug.LogError("Erro: " + ex.Message);
             }
         }
         private IEnumerator WriteResponseAudio(ResponseModel res)
         {
             File.WriteAllBytes(Path.Combine(Application.dataPath, FILENAME_RESPONSE), Convert.FromBase64String(res.intent.audio.content));
             string path = "http://www.raphaelrosa.com/response.wav";
             WWW audioLoader = new WWW(path);
             yield return audioLoader;
             try
             {
                 _GoAudioSource.PlayOneShot(audioLoader.audioClip);
             } catch (Exception ex)
             {
                 Debug.LogError("Erro: " + ex.Message);
             }
         }
This is the console:

Does anyone have an idea of what's causing this?
 
                 
                capture.png 
                (50.5 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by RaphaelVRosa · Oct 27, 2016 at 01:39 PM
I've managed to solve my problem converting my byte array directly in a AudioClip using the code posted by Jeff Kesselman in this topic http://answers.unity3d.com/questions/737002/wav-byte-to-audioclip.html
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                