Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/PrinceOfCookies/CookieOS/llms.txt

Use this file to discover all available pages before exploring further.

Play Music is a mouse-driven audio player built into CookieOS that streams DFPWM-encoded tracks from a remote API directly to a CC:Tweaked speaker peripheral. It supports a live search interface, a playback queue, loop mode, and skip controls — all accessible without a keyboard once a search has been submitted.

Prerequisites

A CC:Tweaked speaker peripheral must be physically attached to the computer before launching Play Music. If no speaker is detected, the program exits immediately with an error. In the Programs menu, the “Play Music” entry is shown in red text when no speaker peripheral is present.

API Backend

Play Music communicates with a hosted audio service at:
https://ipod-2to6magyna-uc.a.run.app/
OperationEndpoint
Search for tracks?search=<url-encoded query>
Download a track?id=<trackId>
Search queries are sent as asynchronous HTTP requests via http.request(). Track downloads use http.request() with binary = true. The raw binary response is decoded on the fly using cc.audio.dfpwm.make_decoder() and fed to speaker.playAudio() in 16 KB chunks.
Only DFPWM audio is supported. If the downloaded file begins with the RIFF header (i.e. it is a WAV file), the program raises an error and stops playback. Do not attempt to queue WAV files from the API.

Interface

The player UI is split into two tabs, switchable by clicking the left or right half of the top bar.

Now Playing Tab

Displays the current track name (white text) and artist (light-grey text). When nothing is loaded, the label reads “Not playing”. Below the track info, three buttons appear on the same row:
ButtonBehaviour
Play / StopStarts playback of the current track or stops and resets the decoder. Greyed out when no track or queue is present.
SkipAdvances to the next track in the queue. If the queue is empty and no track is playing, it clears now_playing.
LoopToggles loop mode. When active, the button is displayed with a white background and black text to indicate it is on. When loop is on, the current track restarts instead of advancing the queue.
The queue is also listed on the Now Playing tab, showing each song name and artist in order.

Search Tab

Contains a search bar (rows 3–5) and a results list below it.
1

Open the search bar

Click anywhere in the light-grey search bar area. The bar turns white and a standard read() prompt appears.
2

Type your query and press Enter

The query is URL-encoded and sent to the API. The bar reverts to showing the last search term and a “Searching…” label appears while the HTTP request is in flight.
3

Browse results

Results appear as a list of song name / artist pairs. Click either line of a result to open the song options screen.
4

Choose an action

A full-screen options overlay replaces the search view with four choices:
OptionEffect
Play nowSets the song as now_playing and starts playback immediately.
Play nextInserts the song at the front of the queue (table.insert(queue, 1, ...)).
Add to queueAppends the song to the end of the queue.
CancelDismisses the overlay and returns to search results.

Playback Controls Summary

All controls are mouse-driven. Keyboard input is only used when typing a search query.
ControlLocation
Switch tabClick left half (Now Playing) or right half (Search) of the top bar
Play / StopClick the Play or Stop button on the Now Playing tab
SkipClick the Skip button on the Now Playing tab
Loop toggleClick the Loop button on the Now Playing tab
Open searchClick the search bar on the Search tab
Select a resultClick the song name or artist row in the results list

Queue Behaviour

Songs in the queue are stored in a Lua table and played in order. When the current track’s DFPWM stream reaches its end:
  • If loop mode is on, playing_id is set to nil, causing the same track to be re-downloaded and restarted.
  • If loop mode is off and the queue has entries, the first entry becomes now_playing and is removed from the queue.
  • If loop mode is off and the queue is empty, now_playing is cleared and playback stops.
The Programs menu displays “Play Music” in red text if no speaker peripheral is detected at launch time. Attaching a speaker and re-opening the Programs menu will restore the normal white text.

Build docs developers (and LLMs) love