|
Post by hipsterdufus on Jun 30, 2023 22:18:30 GMT
Hi, I am trying to play a random song within a playlist and I can get it to function but I can hear the previously started song fade out and the new song fade in. I'd like to be able to play a random song without hearing the previous song fade out.
Here is the code I am using to play a random song in a playlist:
public static void PlayRandomSongInPlaylist(string playlistName)
{
MasterAudio.StopAllPlaylists();
MasterAudio.StartPlaylist(playlistName);
MasterAudio.TriggerRandomPlaylistClip();
}
I guess the question is how to set or change the current playlist without starting it? Thanks for any help.
|
|
|
Post by DarkTonic Dev on Jul 1, 2023 3:33:07 GMT
Why don't you make the crossfade time zero?
|
|
|
Post by hipsterdufus on Jul 1, 2023 5:47:25 GMT
Thanks that worked. I just thought there would be a way to select the playlist without automatically starting a clip. Luckily I don't believe I need the crossfade so it's fine. Thanks.
|
|
|
Post by DarkTonic Dev on Jul 1, 2023 14:50:21 GMT
There's also a ChangePlaylist command, the second parameter can be passed as false to not play the first song (and not play any song yet).
|
|
|
Post by hipsterdufus on Jul 1, 2023 15:55:29 GMT
Got it thanks. I just have one other minor issue that would be awesome if you could help with. In my game I made a lot of playlists with individual songs because I was having issues with having lots of songs on one playlist. However, I have an issue where if I start a playlist with one song, then I restart the playlist, the music does not start again. For example, in my game when a cutscene starts, I call StopPlaylist(all), then ChangePlaylist(character_theme), then RandomPlaylistClip(), and the music starts and works fine. But when I re-enter the same cutscene the music stops but fails to start again. How can I restart the music? I tried a bunch of other methods but none of them seem to work. Maybe I'm missing some kind of setting to reset the clip?
|
|
|
Post by DarkTonic Dev on Jul 2, 2023 1:12:30 GMT
How exactly are you restarting the Playlist? Are you using code, Event Sounds, or something else?
|
|
|
Post by hipsterdufus on Jul 2, 2023 2:33:13 GMT
I am using code. I'm using this other asset - Dialogue System for Unity. It has integration with Master Audio so I can call Master Audio functions in its sequencer.
Actually I just got it working. I had to explicitly set the Song Id and then call MAPlaylistClip(songid) and it works. I thought it was naming the clip the same name as the playlist automatically because that's what it looked like in the UI but apparently not.
|
|
|
Post by DarkTonic Dev on Jul 2, 2023 2:48:39 GMT
Ok thanks. Dialogue System, I know the author. He's tremendously talented and thorough. We share tips and tricks with each other often. You can't go wrong with his products.
|
|
|
Post by hipsterdufus on Jul 2, 2023 3:41:35 GMT
Yes he is inspiring I don't know how he does it.
|
|
|
Post by DarkTonic Dev on Jul 3, 2023 15:23:57 GMT
Well, he quit his day job. He's full time Unity programmer. Admirable.
|
|