Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Bug AudioSource.PlayScheduled doesn't work as expected if AudioSource has been Paused

Discussion in 'Audio & Video' started by Midiphony-panda, Dec 5, 2023.

  1. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    Hello :)

    Using Unity 2022.3.13f1

    I am having an issue when using AudioSource.PlayScheduled when I have paused the AudioSource, with AudioSource.Pause.

    PlayScheduled works as expected when AudioSource hasn't been started yet : I can reliably sync my game with the music.

    However, if I pause the AudioSource, and try to use PlayScheduled again, the AudioSource will resume playing instantaneously.
    Despite any dspTime I am trying to set, ahead of AudioSettings.dspTime, the AudioSource is always playing instantaneously if it was paused before.

    I do not have this issue if I stop the AudioSource, (re)set the AudioSource time to the time when it has been stopped, and call PlayScheduled.


    Should we be able to use AudioSource.Pause and AudioSource.PlayScheduled together ? Or do I have to Stop->PlayScheduled everytime I want to pause the AudioSource or move its playback time ?

    Thanks in advance !
     
  2. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    407
    I feel like using
    .Pause
    should not be an issue and I don't believe this behaviour is "by-design". I'm glad you got a workaround, but this would certainly be worth filing a bug!

    Thank you for spotting this! :)
     
    Midiphony-panda likes this.
  3. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    I'll try to submit a bug report during the week :)

    Also, I saw you're posting a lot in this subforum : it is very welcome to have a direct contact with a Unity dev !
     
    SeventhString likes this.
  4. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    407
    Thank you for noticing!

    It's not part of the job per se, but no one argues when we spend an hour here and there to support the community. It's much better than looking at the editor compiling :p