Files
ReSkate/Extension/Music/external_audio.h
T
AyeZeeBB 48a9cb8f5b Music: Spotify, YouTube Music and External Audio through the in-game player
Three outside sources can now be played through the game's own music
player. Each has its own row in the music screen, shown only when it is
set up, with tiles that behave like the game's playlists: track name,
cover, pause, next, and pressing a row to start that track.

How the sound gets in
- The game's song decoder is hooked. While one of these tiles is on, the
  audio of the game song behind it (its "carrier") is replaced, block by
  block, with the outside source's audio. The game's volume, fades and
  pausing still apply.
- Rows are songs of our own registered with the game's music registry
  (copies of a real song's asset with their own artist and title), so no
  game song is borrowed or renamed to list a track.

Spotify
- The game is a Spotify Connect device ("ReSkate"), built on librespot
  and linked into ReSkate.dll (SpotifyHelper/, Rust). Audio, track info
  and controls come straight from Spotify. Needs Premium.
- Optional sign-in through the Web API lists the player's playlists and
  Liked Songs as tiles with their tracks.
- librespot can no longer end the process (it does so on a free account
  and on playback errors); only its thread is stopped.

YouTube Music
- Videos and playlists added by link. yt-dlp is fetched on request into
  <Local AppData>\ReSkate\bin and checked against its published sums;
  decoding is done in the DLL, so no ffmpeg.
- Private and age-restricted songs: cookies.txt or a browser's sign-in,
  with QuickJS fetched as the JavaScript runtime yt-dlp then needs
  (Node.js is used instead when installed).

External Audio
- Any app's sound, captured per process from Windows, with the app's own
  output turned down while it plays through the game.

Setup page
- "spotify setup" opens http://127.0.0.1:8421/: device status, sign-ins,
  YouTube links and tools, the external app, loudness. Loopback only;
  changes are accepted from its own page only.

Also
- Speakers in the world play the tile's audio; grabbing one keeps the
  player on their tile.
- Playlists added while the game runs are sent to the music screen live.
- MUSIC-SETUP.md: setup guide for players.

Building the Spotify device and the YouTube decoder needs cargo; without
it ReSkate.dll builds without them.
2026-10-12 03:16:36 -05:00

29 lines
1.3 KiB
C++

#pragma once
#include <string>
#include <vector>
// "External Audio" in the game's music screen: the sound of an application the player picks
// (a browser, a media player), heard through the game as Spotify's is (app_audio_capture.h
// takes it from Windows as it is played, and turns the application's own output down while it
// goes through the game). What it is playing, and play, pause and next, are by Windows' media
// session for it when it has one (external_player.h).
//
// Which application is picked in the setup page (spotify_dashboard.h) and kept in
// <Local AppData>\ReSkate\external-audio.json.
namespace dingosdk::external_audio {
// What its station's playlist is called among the Spotify stations (spotify_station.h).
inline constexpr char station[] = "~external";
inline constexpr char station_name[] = "External Audio";
// Its playlist's id in the music screen, and what the ids of its row there begin with.
inline constexpr char playlist_id[] = "external:audio";
inline constexpr char playlist_prefix[] = "external:";
// The application picked ("chrome.exe"), or empty.
std::string app();
void set_app(const std::string& executable);
// The applications that have sound going to the speakers now, to pick from. Any thread.
std::vector<std::string> apps();
// Whether its station is the one that is on.
bool on() noexcept;
void set_on(bool on) noexcept;
}