Capstone: Build an Interactive Jukebox
Tutorial intermediate compiles

Capstone: Build an Interactive Jukebox

Updated intermediate Scene Graph Sound Code verified

Capstone: Build an Interactive Jukebox

This is where the series pays off. You can play ambient beds (Part 1), fire cues on triggers (Part 2), and loop music for a crowd (Part 3). Now we build the thing that makes a club interactive: a jukebox players walk up to, press, and toggle the music — on, off, on, off.

The stage jukebox: a Button Device wired to the speaker stack

The insight: a jukebox is a button + a speaker + one bit of memory

<!-- section-art:the-insight-a-jukebox-is-a-button-a-speaker-one- --> Capstone: Build an Interactive Jukebox: The insight: a jukebox is a button + a speaker + one bit of memory

Toggle Logic

There's no special "jukebox device." A jukebox is three things you already understand, wired together:

  1. A Button Device — the face the player holds-to-use.
  2. An Audio Player Device — the speaker that actually plays the track.
  3. One logic flag — remembering whether the music is currently on, so each press does the opposite of the last.

That flag is the whole trick. Without it, every press would just call Play() again. With it, a press toggles.

The button gives you the press

A Button Device fires InteractedWithEvent when a player holds-to-use it. Unlike the trigger in Part 2, we'll Subscribe a handler rather than Await in a loop — for a button that just toggles, a subscription is the cleaner fit:

# The Button Device's InteractedWithEvent fires when a player holds-to-use it.
# Subscribe a handler and you have a one-line "press the jukebox" hook. We keep
# a var playing flag so each press TOGGLES the music: on, off, on, off.
JukeboxButton.InteractedWithEvent.Subscribe(OnButtonPressed)

Subscribe registers a function to run every time the event fires, and returns immediately — no loop, no waiting. The handler (OnButtonPressed) carries the rest of the logic.

The full jukebox device

Everything here is something you've met, now combined:

  • An @editable device reference (every lesson) — two of them: the button and the speaker.
  • Play() / Stop() (Part 1) — the speaker verbs, now driven by a press instead of round-start.
  • An event handler (Part 2's Await, here as Subscribe) — InteractedWithEvent hands the handler the agent who pressed.
  • State that drives behaviorvar IsPlaying : logic. The if (IsPlaying?) reads the flag (the ? succeeds when the logic is true); set IsPlaying = ... updates it. This is the toggle.

The two finishing touches

1. A live label. SetInteractionText changes the prompt the player sees when looking at the button. We swap it between "Play the music" and "Stop the music" so the button always tells the truth about what it'll do next. It takes a message, not a string — so we wrap our text with a tiny <localizes> helper, StringToMessage, the standard idiom for turning a plain string into the localizable message UEFN devices expect.

2. Designer-tunable text. Both labels are @editable strings, so a designer can rename them ("Start the show" / "Cut the music") right in the Details panel — no recompile.

Wiring it up in the editor

The build, end to end:

  1. Place a Button Device on the stage (the jukebox face).
  2. Place an Audio Player Device at the speaker stack, set to a looping track.
  3. Add a Verse device running jukebox_device, and drag the button into JukeboxButton and the speaker into StageSpeakers.
  4. Optionally retitle StartLabel / StopLabel in the Details panel.
  5. Press play, walk up to the button, hold-to-use — the music kicks in. Press again — silence.

The finished neon club: dance floor, speaker stacks, lights, and the stage jukebox

You did it

<!-- section-art:you-did-it --> Capstone: Build an Interactive Jukebox: You did it

Audio Mastery

You started this series with a silent room. You can now lay an ambient bed, fire cues off player movement, loop music for a whole lobby, and hand players a button that controls the soundtrack. That same toolkit drives in-game radios, arcade cabinets, boss-fight stingers, zone-based ambience, and a hundred other audio mechanics. The nightclub was just the stage.

Recap

  • A jukebox is a button + an Audio Player + one logic flag — no special device.
  • InteractedWithEvent.Subscribe(handler) runs your handler on every press; the handler receives the pressing agent.
  • A var ... : logic flag plus if (Flag?) / set Flag = ... is the standard toggle pattern.
  • SetInteractionText takes a message; wrap a string with a <localizes> helper to build one, and keep the label in sync with the state.
  • Everything is @editable, so designers wire and tune the jukebox with no code changes.

Get the complete code — free

You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.

Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.

Verse source files

Check your understanding

Test yourself with an interactive quiz and track your progress + earn XP — free for members.

Up next · Scene Graph: Characters Who's Playing? Finding the Player's Character Continue →

Turn this into a guided course

Add UEFN audio — button_device, InteractedWithEvent, toggle state, SetInteractionText, message to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in