title: Unity3D stream audio file from disk
body: <p>I'm building an audio player that needs to be able to play files from disk which aren't available at build time (so users can put their own music in). OGG/WAV files are fine and I need to support both Windows and OSX. I've tried using the <a href="http://docs.unity3d.com/ScriptReference/WWW.html" rel="nofollow">WWW</a> class as such:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.IO;
  
  public class LoadAudio : MonoBehaviour
  {
      AudioSource audioSrc;
  
      // Use this for initialization
      void Start()
      {
          if(audioSrc == null) audioSrc = new AudioSource();
          StartCoroutine(LoadTrack(Path.Combine(Application.streamingAssetsPath, "Track.ogg")));
      }
  
      IEnumerator LoadTrack(string filename)
      {
          var www = new WWW(filename);
  
          while(www.progress &lt; 0.2)
          {
              Debug.LogFormat("Progress loading {0}: {1}", filename, www.progress);
              yield return new WaitForSeconds(0.1f);
          }
  
          var clip = www.GetAudioClip(false, true, AudioType.OGGVORBIS);
  
          audioSrc.clip = clip;
          audioSrc.Play();
      }
  
      // Update is called once per frame
      void Update()
      {
  
      }
  }
  </code></pre>
  
  <p>However, when I run this my debug log message prints out that there is 0 progress a few times, then I get an error that can't be seen in the Console. In the Editor log, I can see this error:</p>
  
  <pre><code>Error: Cannot create FMOD::Sound instance for resource D (Operation could not be performed because specified sound/DSP connection is not ready. )
  UnityEngine.WWW:GetAudioClipInternal(Boolean, Boolean, Boolean, AudioType)
  UnityEngine.WWW:GetAudioClip(Boolean, Boolean, AudioType) (at C:\buildslave\unity\build\artifacts\generated\common\runtime\UtilsBindings.gen.cs:334)
  &lt;LoadTrack&gt;c__Iterator0:MoveNext() (at Assets\LoadAudio.cs:27)
  </code></pre>
  
  <p>This error looks similar to the one raised in this <a href="https://issuetracker.unity3d.com/issues/fmod-sound-instance-for-resource-error" rel="nofollow">Unity bug report</a>, however that was supposedly fixed in version 5.3.0 and I'm using 5.3.4.</p>
  
  <p>Assuming this isn't a bug in Unity, what am I doing wrong? If this is a bug, then does anyone know a workaround?</p>
  
  <p>EDIT: I submitted a bug report to Unity and they confirmed that they have reproduced the bug, but it may be a long time before it is fixed. As such, I would appreciate a way to work around this issue.</p>