|
Post by gracchus on Oct 20, 2015 0:44:02 GMT
I want to trigger a playlist's song to play, by ID, but there's a decent chance the song might already be playing. Behaviour seems to be if retriggering a song, it'll play it again from the start. If it's already playing, then just do nothing.
I can't find a clean way to do this without referring to filenames of the PlaylistControllers current audio clip, but that's no good - our audio is still a work-in-progress so filenames keep changing.
Sorry if I've missed something super basic here!
public string loadSongAtStartup; void Start() { bool songIsAlreadyPlaying = [something???];
if (!songIsAlreadyPlaying) { MasterAudio.TriggerPlaylistClip(loadSongAtStartup); }
}
Cheers.
|
|
|
Post by DarkTonic Dev on Oct 20, 2015 4:57:11 GMT
Detect the song already playing with:
var currentClip = PlaylistController.Instances[0].ActiveAudioSource.clip; var songIsAlreadyPlaying = currentClip != null && currentClip.name == "song name";
Yes you'll need to use the clip's name for this.
|
|
|
Post by gracchus on Oct 20, 2015 5:19:03 GMT
Thanks
|
|
|
Post by DarkTonic Dev on Oct 20, 2015 5:33:47 GMT
No problem.
|
|
|
Post by baroquedub on Dec 12, 2016 0:11:38 GMT
Could you incorporate this into the EventSound component? Seems a shame to have to write a custom script (and lose the sound trigger functionality) just to check if a clip is already playing in the playlist - maybe a simple option below 'Retrigger Limit Mode', e.g. Simple tickbox: Retrigger if playing.
Or am I missing something ?(apologies, just bought the asset and am a completely newbie)
|
|
|
Post by DarkTonic Dev on Dec 12, 2016 0:24:43 GMT
Could you incorporate this into the EventSound component? Seems a shame to have to write a custom script (and lose the sound trigger functionality) just to check if a clip is already playing in the playlist - maybe a simple option below 'Retrigger Limit Mode', e.g. Simple tickbox: Retrigger if playing. Or am I missing something ?(apologies, just bought the asset and am a completely newbie) For which action? Please take a screen shot of where you'd like it to appear with everything else already set up.
|
|
|
Post by baroquedub on Dec 12, 2016 0:35:55 GMT
Just a simple Trigger Enter, as per your video tutorial:
|
|
|
Post by DarkTonic Dev on Dec 12, 2016 20:24:07 GMT
Got it, thanks. Added to roadmap.
|
|
|
Post by baroquedub on Dec 12, 2016 21:12:24 GMT
No worries. Thanks for two quite awesome plug-ins
|
|
|
Post by DarkTonic Dev on Dec 13, 2016 2:32:09 GMT
You're welcome.
|
|
|
Post by DarkTonic Dev on Feb 26, 2017 2:16:26 GMT
I was about to code this, but surprising it already works the way you want, by default.
|
|
|
Post by IlmariH on Dec 22, 2021 11:46:57 GMT
Hi - just bumped into this same problem but didn't find a way to handle it without scripting.
From the dev reply i understood that it would be possible to not trigger a playlist item if it's already playing, but i didn't find a way to do this in the Event Sound component.
A solution suggested by baroquedub would be quite handy, adding a simple tickbox "Retrigger if playing", which would make it possible to not trigger an item if it's already playing.
|
|
|
Post by DarkTonic Dev on Dec 22, 2021 15:47:32 GMT
You could always use Visual Scripts, like Playmaker or Bolt, to perform the check. Most people who don't write code use something like that.
|
|