|
Post by artaka on May 16, 2014 17:41:08 GMT
Hey, Is there a way I can Trigger or Queue a playlist audio clip to start at the middle of the clip instead of the beginning? Thanks
|
|
|
Post by DarkTonic Dev on May 16, 2014 23:24:29 GMT
If it's the first clip in a playlist you're playing, there's no way to do it without code. If it's the 2nd clip or so, you can use a Synchronized playlist, then the new song will keep the time position. Would that work? If not, I'll look up some code to change the position of the song the instant it starts.
|
|
|
Post by artaka on May 16, 2014 23:53:06 GMT
Unfortunately that won't work. I do need to try to start the first track and possibly consecutive tracks at specific points in the track depending on the state of the game. What I tried to do is set the lastKnownTimePoint of the clip to a different time before triggering it. It seems to work for all tracks except the first one. It would be great to be able to set the startTime of each track in the playlist at runtime ( including the first one ). Below is my attempt:
public static class MasterAudioExtensions { public static bool TriggerPlaylistClip(string playlistControllerName, string clipName, float startTime) { List<MusicSetting> clips = PlaylistController.InstanceByName(playlistControllerName).CurrentPlaylist.MusicSettings; for (int i=0;i<clips.Count;i++) { if (clips[i].clip.name == clipName) { // start time is in seconds. Must convert it to samples first clips[i].lastKnownTimePoint = (int)(clips[i].clip.frequency * startTime);
return MasterAudio.TriggerPlaylistClip(playlistControllerName, clipName); } } return false; } }
|
|
|
Post by DarkTonic Dev on May 17, 2014 0:22:47 GMT
You can change line 989 in PlaylistController.cs (private to public) to this:
public AudioSource ActiveAudioSource
Then, after you TriggerPlaylistClip to the new song, use this code:
var controller = PlaylistController.InstanceByName("yourControllerName"); controller.ActiveAudioSource.timeSamples = 1000; // instead of 1000, use your calculated value.
I'll change that line 989 in the next version.
|
|
|
Post by artaka on May 17, 2014 5:22:53 GMT
That worked! Thanks you!
|
|
|
Post by DarkTonic Dev on May 17, 2014 6:05:39 GMT
No problem.
|
|
|
Post by artaka on May 17, 2014 15:25:50 GMT
It would be great if you could add startTime attribute to every playlist track and expose it in the Inspector. That way we could easily define a starting point for every clip and it would auto advance to the defined time. Thanks
|
|
|
Post by DarkTonic Dev on May 17, 2014 19:01:30 GMT
Ok I'll add it to the list.
|
|
|
Post by artaka on May 24, 2014 6:06:04 GMT
Hey Brian, Is this something you think you may be able to add to MasterAudio soon? I'm currently working on implementing all the music and was wondering if I should wait for your addition or hack around it. Thanks
|
|
|
Post by DarkTonic Dev on May 24, 2014 7:48:17 GMT
Actually I just figured out a way to do it. Should be live tomorrow. There's a new field "Start Time (seconds)" under each song in a playlist, only for Song Transition Mode "New song from beginning".
|
|
|
Post by artaka on May 24, 2014 14:30:27 GMT
That is great!!! That's precisely what I need. Can't wait to get my hands on it. Thanks a bunch
|
|
|
Post by DarkTonic Dev on May 24, 2014 19:26:52 GMT
No problem.
|
|