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

Bug: when you AudioSource.Pause() then Play(), the component will stop checkin "loop" flag

Discussion in 'Audio & Video' started by xpistos, Jan 29, 2015.

  1. xpistos

    xpistos

    Joined:
    May 19, 2014
    Posts:
    3
    Hi,

    I'm new to the forum. I tried to post the bug in the IssueTracker tab but saw no way to submit issues there, so I came here.

    I just discovered a weird behaviour with AudioSource.

    Steps to repro:
    1) add an AudioSource Component to an object and set a clip (in my case a music track)
    2) set the component to play on start and NOT LOOP
    3) add a script that Pause()s then Play()s the clip in the AudioSource component right after the game starts and the clip has started playing.
    4) notice at the end of the clip, the AudioSource will now loop the clip, even if you force set the AudioSource.loop = false right after the Play()

    Is this the designed behaviour of the AudioSource component?
    Am I doing this wrong?

    Thanks in advance for any help with this issue!
     
  2. xpistos

    xpistos

    Joined:
    May 19, 2014
    Posts:
    3
    Can anybody help with this AudioSource bug?

    It might sound minor, but it's realy causing a bad experience with our app's users.

    Thanks again!



     
  3. boolfone

    boolfone

    Joined:
    Oct 2, 2014
    Posts:
    289
    I tried to reproduce what you are seeing, but I didn’t see looping.

    I used this code:

    Code (CSharp):
    1.     // Use this for initialization
    2.     void Start () {
    3.         AudioSource audio = this.GetComponent<AudioSource> ();
    4.         audio.Pause ();
    5.         audio.Play ();
    6.     }
    Also, can you explain why you are calling Pause()?

    Thanks.