Audio plays in editor, but not on mobile

Asked

Viewed 73 times

3

I’m making a narrated game for Android in Unity 5 with c#, I use the following function to pick up the audio from Google’s voice. However it works only in the editor, when I have it installed on the mobile the audio does not play, I checked if the device has sound, increased the volume, tried on 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 ]);, that 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 looked everywhere, and I haven’t found a way around it.

  • It may be the format of the audio, remember that some formats were not played on the mobile because it has no support.

  • I also thought that, but the audio is in MP3, and the phone plays other mp3 files normally.

  • I would try a WAV if I were you, remember that the player that plays the system sounds is different.

  • Then, there is the problem that I’m using this link to get the audio " http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=" + textoATocar2 + "&tl=Pt-Gb ", that I need a variable audio, which I picked up by google, which only provides in mp3

1 answer

0

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.