Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Jukebox Plus — Enhanced Audio Control for Roll20

1751417762

Edited 1752030579
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Jukebox Plus [ Video Demo ] Available in One-Click Install Jukebox Plus is a Mod Script for Roll20 that expands and improves the built-in jukebox, focusing on giving GMs more organized, flexible, and intuitive control over in-game audio. I wrote this because playlists are a bit limited in the standard jukebox, and I could never remember what a track sounded like by the title. This allows for descriptions, images, and as many Albums (tags) as you like. The linked video demonstrates the script in action. Once this has been previewed, I'll try to squash any bugs or deal with requested features—no guarantees :) —before sending to the One Click repo for easy installation. List o' Features: Support for custom albums (tags) and playlists for sorting and organizing tracks Editable track descriptions and optional image previews A clean sidebar and track interface with light and dark mode options Easy controls for play, stop, loop, isolate, and bulk actions like "Play All" and "Stop All" Announce function to send styled “Now Playing” messages to the chat, including image and text A Find command to search track names and descriptions, grouping results in a temporary "Found" album Identifies duplicate tracks Backup and restore tools to preserve playlists, tags, and track metadata between games (moderate fidelity, use with this in mind) The script is designed to be easy to use and maintain, making it ideal for games where music and atmosphere play an important role. This video demo walks through the interface and showcases how to use it to manage your Roll20 audio. Getting Started Jukebox Plus lets you organize and control music tracks by albums or playlists. Use the toggle buttons in the sidebar to switch between views. Tracks are displayed on the right, and control buttons appear for each one. Header Buttons At the top right of the interface: • Play All — Plays all visible tracks simultaneously. Limited to the first five visible. • Stop All Audio — Stops all currently playing tracks • Loop All — Sets loop mode for all visible tracks • Unloop All — Disables loop mode for all tracks • Find Tracks — Search all track names and descriptions for the keyword. All matching tracks will be assigned to a temporary album called Found. You can then switch to the Found album to quickly view the results. To clear the results, simply delete the Found album using the utility panel. If you input "d" as the search term it will create a temporary play list of any duplicate tracks, grouped by name. • Help — Displays a full help page. Click Return to Player to return. Sidebar: Navigation & Now Playing View Mode Toggle The left sidebar lists all albums or playlists, depending on the current view mode. Clicking a name switches the view. These buttons let you switch between organizing by Album tags or by manual Playlists. Albums are groupings of tracks that you define through Jukebox Plus. You can make as many of these as you like, and any track may belong to multiple Albums. Playlists are managed by the Roll20 Jukebox interface. You can view and play them here, but you cannot move them about. At the bottom of the list is: — filters the list to show only tracks currently playing. Track Controls Each track shows these control buttons: Play : Start the track. Loop : Toggle loop mode for the track. Isolate : Stops all others and plays only this one. Stop : Stops this track.  ➤  Announce : Sends the track name and description to the chat window. Example: Track Info and Management • Click the track description "edit" link to create a description. You can use "//" to insert a line break. • Each track has a Playlist tag, and the ability to add album tags. Playlist tags are in blue, and Album tags are in red. Click + Add to add a track to an Album. Click a Playlist or Album tag to jump immediately to that Playlist or Album. Click the "x" in an Album tag to remove the track from that Album: Album name | x • Click the image area to submit a valid image URL. This will be used as the image for that track. It will be cropped to fit a 100px square. The URL can come from your Roll20 image library or any valid image host. Utility Panel Click Settings ▾ to expand the utility tools. Includes: These buttons change the name of an album, add a new album, or remove the currently selected album. There is no verification, so use with care. These buttons switch between light and dark mode. Rebuilds the interface if something breaks. These buttons create a backup handout of the custom data you have entered: playlists, descriptions, and images. Higher numbered handouts are later backups. You can restore from a backup if your data gets screwed up, or you can transmogrify the handout, or copy it to a new game, and restore from there. This is a useful way to move your customizations from game to game. Use with caution. Roll20 stores tracks by ID number which are different in every game, and the script tries hard to match title to ID. If you have multiple tracks with the same name or have renamed a track, this may not perform as expected. Useful Macros Here are some chat commands that can be used in macros: !jb — Puts a link to this handout in chat !jb play TrackName — play the named track !jb stopall — stops all audio !jb loopall — sets loop mode on all visible tracks !jb unloopall — disables loop mode on all tracks !jb jump album AlbumName — switch to a specific album !jb help — open this help screen !jb find keyword — command to search all track names and descriptions for the keyword. All matching tracks will be assigned to a temporary album called Found. You can then switch to the Found album to quickly view the results. To clear the results, simply delete the Found album using the utility panel. !jb find d — command to search all track names duplicate tracks. All duplicate tracks will be assigned to a temporary album called Duplicates. You can then switch to the Duplicates album to quickly view the results. To clear the results, simply delete the Duplicates album using the utility panel. You can also discover commands by pressing a button, clicking in the chat window, and pressing the up arrow to see what was sent.
Hello Keith, I watched the video and I can't wait to test it, the functionalities you put in this script are really usefull ! 
1751474452
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks! When you try, if you run into any bugs, please let me know. You can also try re-installing from the code, fresh. I have discovered a few bugs and have already replaced the code in that link multiple times. :) I am working on ways to remove orphaned tracks (tracks you deleted that are still in the database, or were pulled into the database from a backup, etc.) The logic on that is tricky.
1751480579
Pat
Pro
API Scripter
Hey, Keith - I was looking at this and the orphaned track issue was showing up on the emitter script I had a while back and was tinkering with. Is it something to do with jukebox or is there something like the old GMNotes issue where it wouldn't update until the save occurred on the main panel? 
1751483897
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
In my case, there are two databases to deal with, the game database, and the script database. The script database is vital, because it holds all of the images, descriptions, and art. Reconciling the two is where the issue comes in. Currently, when you do a restore from the backup, it has to match titles in the script data to titles in the jukebox data, and then update the ID if there is no match. This is pretty much the whole script database if you are moving from one game to another. If there is no match, then you can wind up with an orphaned track: Data in the script, but no matching data in the jukebox. I have been working on an update where if you play a track and there is no match, you have the option to automatically remove that script from the script DB. Most of the time, that's fine, but there are edge cases where there is a matching title in both, but they just can't find each other. This can play out a number of ways: The track is actually playing, but not really, because of the long standing jukebox bug where some titles never really start (time is 0:00) until you restart the game The track doesn't play because an PI call doesn't resolve until you play the track manually first (an API/Roll20 issue, that I'm trying to get together with the Aaron on) Something got confused somewhere (harder to pin down). But if you have already added art and description to an orphaned track, you might not want to delete it from the script DB. The Refresh button can fix a lot of simple cleanup of the script db, but it can't resolve track IDs. I'm a little leery of a blanket solution there.  I'm leaning towards a per-track re-associate command of some kind.
1751484140
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
One of the annoying things is that Roll20 knows how to set a track to "playing", but it can't really report when the playing has finished. Thus when you hit the play button in the script, it stays red until you manually stop it. There's currently no way around that other than the "stop all" command. I should probably roll that into the Refresh button, but I don't know if stopping all music is desirable behavior for that button. Probably it is, but...
1751508203

Edited 1751580632
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Updates (Patched to code link in top post): Alphabetical sorting of tracks and albums. Track count in the header Backup handouts now live in the Archive, to avoid cluttering the Journal Tab. Can still be transmogrified. Better ordering of settings Better handling of broken tracks (internal) Adding control tags to descriptions. Anywhere in the description add: !a, !announce = Track will auto-announce when played. Default is to use the manual button next to the track name. !d, !desc = Track will include description when announced. Default is just the title. Description tag now supports limited markdown. Specifically: *italic*, **bold**, `code` --- becomes a paragraph break. Previous version used "//", but this proved to have some parsing difficulties. Added API meta Tags to work with scipts like ScriptInfo (basically, it provides better line numbers for tracking down errors) Figured out how to tell if and when a track stops playing, meaning: Play buttons now respect the play state automatically  (they stop being red when the track ends) The header bar has been redesigned slightly for logical grouping of commands includeing new command: Play in Order. When playing all tracks you can decide to play them all together (say for a layered sound scape) or sequentially (for providing non-repeating background music). As long as no tracks are set to looping they will play in the display order. Stopping any track will interrupt the sequence. If tracks are playing concurrently, any tracks set to loop will continue to play until individually stopped, or stopped with the Stop All button. The Find Duplicates feature was really helpful. Because I typically add tracks to playlists in MyAudio, I had no idea I had 57 duplicates in my game. I was able to clean them all out, flush them from the database, delete the myAudio playlists and export clean ones from the game back up to MyAudio.
:- ) 
1751580641
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Figured out how to tell if and when a track stops playing, meaning: Play buttons now respect the play state automatically (they stop being red when the track ends) The header bar has been redesigned slightly for logical grouping of commands includeing new command: Play in Order. When playing all tracks you can decide to play them all together (say for a layered sound scape) or sequentially (for providing non-repeating background music). As long as no tracks are set to looping they will play in the display order. Stopping any track will interrupt the sequence. If tracks are playing concurrently, any tracks set to loop will continue to play until individually stopped, or stopped with the Stop All button.
1751617151
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Added a Mix option to the Play All. When this button is pressed, any looped track(s) in the displayed tracklist are played continuously. All non looped tracks are played at random intervals. The idea here is to create a changing soundscape. Example Album: Rainstorm (on Loop) Thunder 1  Wolf Howl Will give the effect of a rain storm with random thunder crashes and wolf howls.
1751700719
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
If I don't put this into the One Click Repo, I'm going to tweak it to death. It has been submitted for the One Click repo...
1751772337
Victor B.
Pro
Sheet Author
API Scripter
keithcurtis said: One of the annoying things is that Roll20 knows how to set a track to "playing", but it can't really report when the playing has finished. Thus when you hit the play button in the script, it stays red until you manually stop it. There's currently no way around that other than the "stop all" command. I should probably roll that into the Refresh button, but I don't know if stopping all music is desirable behavior for that button. Probably it is, but... It does.  This code detects track end.       RegisterEventHandlers = function() {         on('chat:message', inputHandler);         on('change:jukeboxtrack',changeHandler); changeHandler = function(obj,prev){     var id, listFound = false, trackDetails, trackFound = false     //we receive the track object from jukebox.  softstop is set to true upon finish         if(obj.get('softstop')===true && prev.softstop === false){
1751784847
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks Victor! Fortunately, I did figure this out. I just hadn't been paying attention to the properties in the Jukeboxtrack object. It made other stuff possible, like the rando mized soundscape Mix feature.
1752030688

Edited 1752106675
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The script is now available for One Click installation on your campaign Mods page.