Post by sarahnorthway on Aug 19, 2021 23:28:39 GMT
I have a song in a playlist which I would like to start at a very specific frame to match an animation. The Audio Origin is a Resource File which is set to Load in Background with Load Type of Streaming. If I trigger it at the specific frame using PlaylistController.TriggerPlaylistClip(), it will start playing at a different time depending on how fast your system is, because MA/Unity needs to load it from the resources folder then buffer a few seconds into memory (or however Unity does streaming). On some machines it's a few seconds out of sync with the animation.
How best to preload this track so it's ready to go?
I thought I should be able to Pause it, but calling PlaylistController.PausePlaylist() immediately after TriggerPlaylistClip doesn't pause the track.
It keeps playing. Even though my PlaylistController.CurrentPlaylistSource.crossFadeTime is set to 0, I'm guessing MasterAudio waits some number of frame(s) before it swaps which playlist is the current one? Looks like waiting 1 frame before pausing is not long enough - still plays. Waiting 2 frames has different bad results - the track stops and unloads. Waiting 60 frames is long enough - the track pauses. But then I need to move the head back to 0 (PlaylistController.CurrentPlaylistSource.Stop then Play) which seems to require re-buffering or something so the track is once again starting too late on some machines.
I'm running in circles here. Is there an easier way to preload a Streaming audio file so I can start it at exactly the right time, play it, then remove it from memory when it's done? Should I even be attempting this with a Streaming file or is it impossible?
How best to preload this track so it's ready to go?
I thought I should be able to Pause it, but calling PlaylistController.PausePlaylist() immediately after TriggerPlaylistClip doesn't pause the track.
It keeps playing. Even though my PlaylistController.CurrentPlaylistSource.crossFadeTime is set to 0, I'm guessing MasterAudio waits some number of frame(s) before it swaps which playlist is the current one? Looks like waiting 1 frame before pausing is not long enough - still plays. Waiting 2 frames has different bad results - the track stops and unloads. Waiting 60 frames is long enough - the track pauses. But then I need to move the head back to 0 (PlaylistController.CurrentPlaylistSource.Stop then Play) which seems to require re-buffering or something so the track is once again starting too late on some machines.
I'm running in circles here. Is there an easier way to preload a Streaming audio file so I can start it at exactly the right time, play it, then remove it from memory when it's done? Should I even be attempting this with a Streaming file or is it impossible?