Hey Guy’s,
I am working on a music player that streams mp3’s from a url. Everything works perfect in the Editor and on my Android devices, but when deployed to IOS I am having issues. My first issue is that IOS will not stream the MP3. It only works if I do a full download on the audio clip and then play it. My second issue is that I have a return button that simply loads a new scene when clicked. When clicking this button during the download/stream attempt of an mp3, IOS freezes instead of going to that scene. I have tracked the freezing issue down to this line of code:
audioSrc.clip = [www.GetAudioClip(false](http://www.GetAudioClip(false), true, AudioType.MPEG);
I have tried everything such as disposing the www,destroying the www,nulling www,and stopping all co-routines before trying to load the new scene and IOS still freezes. I am on Unity 5.3.0f4, so let me know if there has been a bug fix for this, but I couldn’t really find anything. Thanks! Here is what my stream code looks like:
IEnumerator PlaySong(Playlist SongInfo, int index)
{
www = new WWW(EncodeMediaURL(SongInfo.URLsrc));
while (www.progress < 0.10)
{
yield return new WaitForSeconds(0.1f);
}
if (www.error == null)
{
audioSrc = GetComponent();
audioSrc.clip = [www.GetAudioClip(false](http://www.GetAudioClip(false), true, AudioType.MPEG);
if (audioSrc.clip.length == 0)
{
yield return www;
audioSrc.clip = [www.GetAudioClip(false](http://www.GetAudioClip(false), false, AudioType.MPEG); //file cant stream so download it then play
}
StartCoroutine(StartAudio());
}
else
{
Toast.Message(“There was an error loading this song.”);
Debug.Log("Error loading mp3: " + www.error);
}