← Назад к ресурсам

Simple Voice Chat Music Addon

Add music function for Simple Voice Chat mod

Modrinth adventure social utility

Описание

# Music Music is a server-side Fabric mod that streams URL music through Simple Voice Chat. It is built for shared server music with queues, saved playlists, YouTube playlist import, player targeting, personal opt-out, and YouTube OAuth support through Lavaplayer/youtube-source. ## Features - Streams music through Simple Voice Chat static audio channels. - Supports YouTube, YouTube Music, YouTube playlist links, and other Lavaplayer-supported remote sources. - Expands pasted YouTube playlist links into individual songs. - Shows title, creator, requester, duration, queue position, and playback diagnostics. - Cleans YouTube topic-channel creator names, so `Artist - Topic` displays as `Artist`. - One shared server-wide music stream. - Global queue with skip, repeat, and shuffle. - Persistent saved playlists. - Forward/backward seeking by seconds. - Player targeting and exclusion controls. - Player self-service `/music leave` and `/music join`. - Simple Voice Chat "Music" volume category for personal client volume. - Global server volume control. ## Requirements - Fabric Loader. - Simple Voice Chat installed on the server. - Simple Voice Chat installed on clients that want to hear the stream. - A Minecraft version supported by the mod file you install. This mod controls music on the server, but players only hear it through their Simple Voice Chat connection. ## Installation 1. Install Fabric Loader on the server. 2. Install Simple Voice Chat on the server. 3. Install this mod in the server `mods` folder. 4. Players who want to hear the stream must install Simple Voice Chat on their clients. 5. Start the server and run `/music help`. ## Quick Start ```text /music now /music play https://www.youtube.com/watch?v=VIDEO_ID 10 /music queue add https://music.youtube.com/watch?v=NEXT_VIDEO_ID /music queue add https://www.youtube.com/playlist?list=PLAYLIST_ID /music queue list ``` If YouTube asks for login or blocks playback, complete the OAuth device login shown in the server log. ## How It Works 1. A player runs `/music play`, queues a URL, or starts a saved playlist. 2. Lavaplayer loads the URL. 3. YouTube links are handled by `youtube-source`. 4. The mod sends encoded audio frames into a Simple Voice Chat static audio channel. 5. Selected listeners hear the same stream. There is one active global stream per server. Starting a new track with `/music play` replaces current playback and clears the runtime queue. ## YouTube OAuth YouTube may block automated playback clients. This mod supports YouTube OAuth through `youtube-source`. Config file: ```text config/music.json ``` Important fields: ```json { "youtubeOAuthEnabled": true, "youtubeOAuthRefreshToken": "", "youtubeOAuthSkipInitialization": false } ``` First login flow: 1. Start the server. 2. Run `/music play `. 3. Check the server log for the Google device login code. 4. Complete the login in a browser. 5. The refresh token is saved to `config/music.json`. The YouTube login is global for the server, not per player. Keep `music.json` private because it can contain an OAuth refresh token. Using a secondary YouTube account is recommended. ## Commands Run: ```text /music help /music help queue /music help playlist /music help target /music help volume ``` ### Everyone ```text /music help /music now /music queue list /music leave /music join ``` - `/music leave` opts the player out of the music stream. - `/music join` removes the personal opt-out. - Personal volume is controlled with the Simple Voice Chat client "Music" slider. ### Playback All players: ```text /music play /music play /music stop /music pause /music resume /music skip /music forward /music backward /music volume /music repeat off /music repeat one /music repeat queue /music shuffle on /music shuffle off ``` Behavior: - `/music play ` starts immediately and clears the runtime queue. - `/music play ` starts the first playlist track and queues the rest. - `/music play ` starts playback and sets global volume from `1` to `100`. - `/music forward ` seeks ahead in the current track. - `/music backward ` seeks back in the current track. - `/music repeat one` repeats the current track. - `/music repeat queue` loops through the queue. - `/music shuffle on` chooses queued tracks randomly. ### Queue All players: ```text /music queue add /music queue remove /music queue clear /music skip ``` Everyone can view: ```text /music queue list ``` Queue behavior: - The runtime queue is not saved after server restart. - `/music queue add ` appends a track. - `/music queue add ` expands the playlist and appends each song. - Queue metadata loads in the background, so a new item can briefly show as `title loading`. - YouTube creator names ending in ` - Topic` are displayed without that suffix. - If metadata fails, the URL remains queued and playback can still try it. Example output: ```text [Music] Queue: 1. Song Title - Creator Name | 3:22 | requested by PlayerName | added 16:21:05 2. title loading: https://www.youtube.com/watch?v=... | requested by PlayerName ``` ### Saved Playlists All players: ```text /music playlist list /music playlist create /music playlist delete /music playlist show /music playlist add /music playlist remove /music playlist play /music playlist queue ``` Playlist behavior: - Playlists are saved in `config/music-playlists.json`. - Playlist names are single words. - `/music playlist add ` adds one track. - `/music playlist add ` imports every song from the YouTube playlist. - `/music playlist play ` replaces current playback and starts the playlist. - `/music playlist queue ` appends the saved playlist after the current queue. Example: ```text /music playlist create lobby /music playlist add lobby https://www.youtube.com/watch?v=SONG_1 /music playlist add lobby https://www.youtube.com/playlist?list=PLAYLIST_ID /music playlist play lobby ``` ### Targeting All players: ```text /music target all /music target only /music target add /music target remove /music target show /music exclude add /music exclude remove /music exclude clear ``` Targeting order: 1. Connected Simple Voice Chat clients. 2. Include filter if set. 3. Exclude filter. 4. Player personal opt-out from `/music leave`. Personal opt-out always wins. `/music target all` does not force opted-out players to listen. Examples: ```text /music target all /music target only Steve /music target add Alex /music exclude add Steve /music exclude clear ``` ## Config Files Main config: ```text config/music.json ``` Stores YouTube OAuth settings, repeat/shuffle settings, target filters, exclusions, and player opt-outs. Playlist config: ```text config/music-playlists.json ``` Stores saved playlist names and track entries. Example playlist shape: ```json { "playlists": { "lobby": [ { "url": "https://www.youtube.com/watch?v=SONG_1", "title": "Song Title", "creator": "Creator Name", "requestedByName": "server", "durationMillis": 202000 } ] } } ``` Use commands instead of editing playlist files while the server is running. ## URL Support Good candidates: - Normal YouTube watch links. - YouTube Music watch links. - YouTube and YouTube Music playlist links. - Direct audio file URLs supported by Lavaplayer. - Some direct video URLs with extractable audio. Less reliable: - Spotify page links. - Private or age-restricted videos. - Region-blocked videos. - YouTube links blocked by bot detection. Unsupported URLs should fail with a chat error instead of crashing the server. ## Command Access All players can use every `/music` command, including commands that change server playback state: - Play, stop, pause, resume, skip, forward, backward. - Queue add/remove/clear. - Playlist create/delete/add/remove/play/queue. - Target and exclude filters. - Repeat, shuffle, global volume. Self-service and view commands: - `/music help` - `/music now` - `/music queue list` - `/music leave` - `/music join` ## Troubleshooting ### Music Says Playing, But Nobody Hears It Run: ```text /music now /music target show ``` Check: - Simple Voice Chat is connected. - The voice target/listener count is not `0`. - The player did not run `/music leave`. - The player is not excluded by `/music exclude`. - The client Simple Voice Chat "Music" slider is not at `0%`. - The global volume is not too low. ### YouTube Says Sign In Or Bot Check Enable OAuth in `config/music.json`, restart, then run: ```text /music play ``` Complete the device login shown in the server log. After that, `youtubeOAuthRefreshToken` should be saved. ### Queue Names Show As Loading Or Unknown Metadata is loaded asynchronously. Wait a few seconds and run: ```text /music queue list ``` If metadata still shows unknown, Lavaplayer could not resolve metadata for that URL. The mod will still try to play the URL when its turn starts. ### A Player Does Not Hear Music After Target All Check if the player opted out: ```text /music target show ``` The player can rejoin with: ```text /music join ``` Personal opt-out has priority over target filters. ## Notes - This mod does not download songs to disk. - YouTube playback can still fail if YouTube blocks a client or changes player behavior. - YouTube topic-channel authors are cleaned for display; for example, `Artist - Topic` becomes `Artist`. - OAuth improves YouTube reliability but should use a secondary YouTube account. - Server-side per-player volume is not implemented; use the Simple Voice Chat client "Music" slider for personal volume.