Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: monkey0506 on Thu 07/07/2011 07:19:18

Title: MODULE: Playlist - It's a playlist module! - Updated 6 Feb 2012 (Working Link)
Post by: monkey0506 on Thu 07/07/2011 07:19:18
In response to this totally awesome thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=43916.0), I decided to make a module to handle music playlists! I'm aware of course that we already have AudioClip.PlayQueued, but that's a pretty basic and limiting function if you want to implement a full music player into your incredible AGS games!

I'm on a tight schedule to get out all of my Release Somethings, so I haven't typed up all of the documentation for this yet, but the call tips should be enough to get you started, and hopefully everything is intuitive enough that documentation isn't really completely necessary.

Download v1.1 (http://duals.agser.me/Modules/Playlist_v1.1.rar)

For now, I'll explain a few things. First, an example:

Example:

// game_start
Playlist.AddClip(aMusic1); // add our clips to the playlist
Playlist.AddClip(aMusic2);
Playlist.AddClip(aMusic3);
// ..etc.
Playlist.Repeat = eRepeat; // set the playlist to repeat
Playlist.Shuffle = ePlaylistShuffleAll; // set the playlist to shuffle
Playlist.Play(); // starts the playlist playing!

// on_key_press
if (keycode == '[') Playlist.PlayPrevious(); // play the previous track
else if (keycode == ']') Playlist.PlayNext(); // play the next track
else if (keycode == ' ')
{ // spacebar
  if (Playlist.IsPaused) Playlist.UnPause(); // if the playlist was paused, unpause it
  else Playlist.Pause(); // otherwise, pause it
}


Okay, so I'm hoping this is straightforward enough, especially with the comments, so as to clarify what's going on. But I'll try to break it down. Please bear in mind that I plan to release a demo with resplendent GUI to exhibit this module, but since the majority of the codebase is (apparently) stable, I figured why not release it upon the world and let you help me debug? :=

06 February 2012

v1.1 is here! Changes include:

- New enum PlaylistRepeatStyle: eOnce and eRepeat are still valid, but this was needed to add ePlaylistRepeatOne, so that you can now repeatedly loop a single clip.

- Added functions Playlist.Save and Playlist.Load: This allows you to store multiple playlists. Since there is not currently a global array of AudioClips, this list can only be persisted in-game, and across save games. That is, you cannot save a playlist to a file and read it back.

- Added Playlist.PlayFrom, to allow you to play a specific clip in the playlist, by index. This will start the playlist playing if it is not.

- Added Playlist.Resume as a synonym for Playlist.UnPause.

- Added properties Playlist.Volume and Playlist.Mute. Playlist.Volume is a shortcut to Playlist.Channel.Volume, with the exception that it can be persisted even when Playlist.Channel is changed or is null. Playlist.Mute of course just temporarily sets the channel volume to 0, but this does not affect the Playlist.Volume.

- Added stopClipIfPlaying optional parameter to Playlist.Remove to allow you to override the default behaviour, which is to stop the current playing clip and skip to the next if it is the clip being removed from the playlist.

- Fixed Playlist.Clear resetting the Repeat and Shuffle styles.

- Fixed bug if an invalid clip was specified to Playlist.RemoveClip.

- Removed some debugging code that was inadvertently left in v1.0 of the module.

- Included documentation!! Yay! o/

Thanks guys, and hope you like the module!

Download v1.1 (http://duals.agser.me/Modules/Playlist_v1.1.rar)

P.S. It improves your sex life! No, really! Kick some sexy audio tracks into your game and then hook this playlist functionality in and you sir will go "All night long, all night!" ;D
Title: Re: MODULE: Playlist - It's a playlist module!
Post by: tzachs on Thu 07/07/2011 14:17:10
Dude, you're on fire!
Releasing 2.5 useful modules in a couple of days, you make the rest of us look bad...

Anyways, the interface on this one looks very friendly, just one comment:
I think that's "Resume" is more suitable than "UnPause" as I believe that's the standard used.
Title: Re: MODULE: Playlist - It's a playlist module!
Post by: monkey0506 on Thu 07/07/2011 17:10:37
Yes, very well then. I shall add a synonym function just for you sir. :=

But first, to go get my truck out of the shop and give away all of my monies! Hooray! 8)
Title: Re: MODULE: Playlist - It's a playlist module!
Post by: FamousAdventurer77 on Thu 07/07/2011 18:20:03
*insert Nathan Explosion esque "Awwwwwweessssssome!" here*

Ooh I can't wait to implement this sucker.
Title: Re: MODULE: Playlist - It's a playlist module!
Post by: monkey0506 on Fri 15/07/2011 19:15:49
I'm developing v1.1 as we speak, and see, part of the reason I wanted to make a functional music player as a demo is to better understand what type of features you might want/need out of such a module as this. So, things to look forward to in the upcoming version:

- A new enum to allow for "repeat one" functionality instead of only repeating all or none of the tracks.
- Playlist.Save and Playlist.Load to allow you to store multiple playlists (NOTE: Since AGS doesn't currently have a "generic" way of accessing the audio tracks, the playlists can only be saved per game-session. Save games would be able to store this information, but you can't save it to an external file since there would be no way for the module to read it back.)
- Playlist.Resume! Which just calls Playlist.UnPause! :=
- Playlist.Volume and Playlist.Mute!
- Documentation!!1

If you would like to be able to save playlists to an external file, or use the Playlist module to read external audio files, show your support (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=43407.msg585273#msg585273)!

Also, this:

(http://img593.imageshack.us/img593/1200/teaserw.th.png) (http://img593.imageshack.us/img593/1200/teaserw.png)

Everything in the lower half is functional except the "Rewind" and "Fast Forward" buttons and the "Seek" slider. Nothing in the upper half is functional yet! :=

Please let me know if there's any other specific features that v1.0 is missing and I'll try to include them in v1.1!
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 06 Feb 2012
Post by: monkey0506 on Tue 07/02/2012 04:29:44
*Bump* for new version! 8)
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 06 Feb 2012
Post by: Georgeqgreg on Tue 07/02/2012 12:17:41
THANK YOU MONKEY!!!  ;D
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 06 Feb 2012
Post by: on Wed 08/02/2012 04:41:19
Nice job, I may have to replace my in-game jukebox with this. One question though, when can we expect CD audio and an eject cd-tray option? And how about being able to select a folder full of mp3's/oggs from the games folder (a bit like RCT3, where you fill a particular subfolder full of your own mp3s?) I'd love for my players to be able to play their own cd's or music folders in-game :)

Also, is music only capable of being in one track? For instance, could it be possible to have the playlist fadeout (then mute, possible pause too) and then let the game play a set piece of music and once that's finished have the playlist fade in and continue? Wishlist features that's all ;) What you've already done will certainly simplify things a lot.
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 06 Feb 2012
Post by: monkey0506 on Wed 08/02/2012 04:46:43
Interesting suggestion about CD tracks. Presumably...hmm..yes, I could actually make that work I think.

As for loading external audio, AGS 3.2 removes that ability, which this module explicitly depends upon (as it uses the AudioClip and AudioChannel types, amongst other things). If you look a few posts up I linked to a suggestion to implement a dynamic audio type to read audio files from disk as this is a regression against prior AGS versions...didn't get much attention though.

By the way, I don't know what I was drinking when I wrote half of this code, but there's a million rather obvious bugs in even the latest version. It's functional, but if you use the wrong function the wrong way then it explodes violently. I'm working on fixing that. :P
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 06 Feb 2012
Post by: Fortun on Thu 12/09/2013 16:14:19
Maybe it's not that good idea to revive this dead topic, but... is it possible to get a mirror to this module, or something like that? Only link to module is dead :(

Title: Re: MODULE: Playlist - It's a playlist module! - Updated 06 Feb 2012
Post by: Dualnames on Mon 23/09/2013 21:11:31
http://duals.agser.me/Modules/Playlist_v1.1.rar

Updated the wiki and this topic. Have a blast.
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 25 Sept 2013 (Working Link)
Post by: Georgeqgreg on Mon 23/09/2013 21:41:38
Great, this helps me too. I lost the original in a hard drive crash. I guess that's thanks from both of us! :cheesy:
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 6 Feb 2012 (Working Link)
Post by: jamesreg on Sun 27/09/2015 03:40:07
Does this still work?
Will this allow me to allow a player to create a playlist in game?
Say have a list of songs they can select and as they select them it will add them to a playlist?
Title: Re: MODULE: Playlist - It's a playlist module! - Updated 6 Feb 2012 (Working Link)
Post by: Baguettator on Sat 28/11/2020 19:06:57
Hi there ! I would like to download this module , but the link seems to be dead... Any reason for that ?