Audio plays in editor, but not on mobile

3

I'm doing a narrated game for Android in Unity 5 with C #, I use the following function to pick up the google voice audio. But it works only in the editor, when I have it installed on the phone the audio does not play, I checked if the device has sound, I increased the volume, tried other devices and always the same thing.

public AudioSource _audio;
public string textoATocar;


// Use this for initialization
void Start () {
   _audio = gameObject.GetComponent<AudioSource> ();
}

public void tocaIsso( string audioTocar){
   StartCoroutine( DownloadAudio( audioTocar ) );
}

IEnumerator DownloadAudio( string textoATocar2 ){
   string url = "http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=" + textoATocar2 + "&tl=Pt-gb";
   WWW www = new WWW(url);
   yield return www;

   _audio.clip = www.GetAudioClip( false, true, AudioType.MPEG );
   _audio.Play();
}

Ps: I call the function like this, textAudio.tocaIsso(opcoesMenu[ posicaoMenu ]); , which serves to narrate the menu.

Edit: I updated my Unity to the latest version and now an error appears,

Error: Cannot create FMOD::Sound instance for resource Ȯ1C, (Operation could not be performed because specified sound/DSP connection is not ready. )
UnityEngine.WWWAudioExtensions:GetAudioClip(WWW, Boolean, Boolean, AudioType)
<DownloadAudio>c__Iterator0:MoveNext() (at Assets/Scripts/TextoToAudio.cs:27)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

But I've tried everything, and I have not found a way around it.

    
asked by anonymous 23.10.2017 / 17:50

1 answer

0

I've found that this is a bug in the engine itself, and so far 10/30/2017 it has not been fixed, but it happens in streaming audio.

    
31.10.2017 / 00:38