Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

stream a music problem

Discussion in 'Scripting' started by mtGameDev, Oct 11, 2014.

  1. mtGameDev

    mtGameDev

    Joined:
    Oct 19, 2012
    Posts:
    89
  2. MysterySoftware

    MysterySoftware

    Joined:
    Sep 18, 2014
    Posts:
    46
    WWW is processed on a seperate thread. You should try using an IEnumerator and yield after www.

    Code (CSharp):
    1. IEnumerator LoadSong() {
    2. WWW song = new WWW("http://uploadco.ir/uploads/1hu0x1rt2b17v66uscv.ogg");
    3. while(!song.isDone)
    4. yield return null;
    5.  
    6. audio.clip = song.GetAudioClip(false, true);
    7. audio.Play();
    8. }
     
  3. mtGameDev

    mtGameDev

    Joined:
    Oct 19, 2012
    Posts:
    89
    i tested this code
    but it doesn't work too
    did u test it with my url to hear music ?
     
  4. MysterySoftware

    MysterySoftware

    Joined:
    Sep 18, 2014
    Posts:
    46
    Yes, I did test it. It worked just fine. Remember to start this coroutine in your Start()-method

    Code (CSharp):
    1. void Start() {
    2. StartCoroutine(LoadSong());
    3. }
     
  5. mtGameDev

    mtGameDev

    Joined:
    Oct 19, 2012
    Posts:
    89
    Thanks a lot.
    i think that my pc sound was Mute and i didn't know :-D
    so i couldn't heard sound.
    thanx my friend.