音乐
Music 是一个服务端 Fabric 模组,通过 Simple Voice Chat 流式传输 URL 音乐。它专为共享服务器音乐而设计,支持队列、已保存播放列表、YouTube 播放列表导入、玩家定向、个人退出选项以及通过 Lavaplayer/youtube-source 实现的 YouTube OAuth 支持。
功能
- 通过 Simple Voice Chat 静态音频通道流式传输音乐。
- 支持 YouTube、YouTube Music、YouTube 播放列表链接以及其他由 Lavaplayer 支持的远程音源。
- 将粘贴的 YouTube 播放列表链接展开为单独的歌曲。
- 显示标题、创作者、请求者、时长、队列位置和播放诊断信息。
- 清理 YouTube 主题频道(topic-channel)的创作者名称,使
Artist - Topic 显示为 Artist。
- 一个全局共享的服务器音乐流。
- 具有跳过、循环和随机功能的全球队列。
- 持久化的已保存播放列表。
- 按秒数向前/向后跳转。
- 玩家定向与排除控制。
- 玩家自助命令
/music leave 和 /music join。
- Simple Voice Chat 中的“音乐”音量类别,用于个人客户端音量控制。
- 全局服务器音量控制。
要求
- Fabric Loader。
- 服务器上已安装 Simple Voice Chat。
- 希望收听该流的客户端上也已安装 Simple Voice Chat。
- Minecraft 版本需与你安装的模组文件所支持的版本兼容。
此模组控制服务器端的音乐,但玩家仅通过他们的 Simple Voice Chat 连接听到该音乐。
安装
- 在服务器上安装 Fabric Loader。
- 在服务器上安装 Simple Voice Chat。
- 将此模组安装到服务器
mods 文件夹中。
- 希望收听该流的玩家必须在他们的客户端上安装 Simple Voice Chat。
- 启动服务器并运行
/music help。
快速入门
/music now
/music play 10
/music queue add
/music queue add
/music queue list
如果 YouTube 要求登录或阻止播放,请在服务器日志中完成显示的 OAuth 设备登录流程。
工作原理
- 玩家运行
/music play、排队一个 URL 或开始一个已保存的播放列表。
- Lavaplayer 加载该 URL。
- YouTube 链接由
youtube-source 处理。
- 模组将编码后的音频帧发送到 Simple Voice Chat 静态音频通道中。
- 选定的听众听到相同的流。
每个服务器只有一个活动的全局流。使用 /music play 开始新曲目会替换当前播放并清除运行时队列。
YouTube OAuth
YouTube 可能会阻止自动播放客户端。此模组通过 youtube-source 支持 YouTube OAuth。
配置文件:
config/music.json
重要字段:
{
"youtubeOAuthEnabled": true,
"youtubeOAuthRefreshToken": "",
"youtubeOAuthSkipInitialization": false
}
首次登录流程:
- 启动服务器。
- 运行
/music play <youtube-url>。
- 检查服务器日志中的 Google 设备登录代码。
- 在浏览器中完成登录。
- 刷新令牌将保存到
config/music.json 中。
YouTube 登录对服务器是全局的,而非针对每个玩家。请保持 music.json 私密,因为它可能包含 OAuth 刷新令牌。建议使用次要 YouTube 账号。
命令
运行:
/music help
/music help queue
/music help playlist
/music help target
/music help volume
所有人
/music help
/music now
/music queue list
/music leave
/music join
/music leave 使玩家退出音乐流。
/music join 移除个人退出选项。
- 个人音量通过 Simple Voice Chat 客户端的“音乐”滑块进行控制。
播放
所有玩家:
/music play <url>
/music play <url> <volume>
/music stop
/music pause
/music resume
/music skip
/music forward <seconds>
/music backward <seconds>
/music volume <1-100>
/music repeat off
/music repeat one
/music repeat queue
/music shuffle on
/music shuffle off
行为说明:
/music play <url> 立即开始播放并清除运行时队列。
/music play <youtube-playlist-url> 开始播放播放列表的第一首歌曲并将其余歌曲加入队列。
/music play <url> <volume> 开始播放并设置从 1 到 100 的全局音量。
/music forward <seconds> 在当前曲目中向前跳转。
/music backward <seconds> 在当前曲目中向后跳转。
/music repeat one 重复当前曲目。
/music repeat queue 循环播放队列中的所有曲目。
/music shuffle on 随机选择队列中的曲目。
队列
所有玩家:
/music queue add <url>
/music queue remove <index>
/music queue clear
/music skip
所有人都可以查看:
/music queue list
队列行为:
- 运行时队列在服务器重启后不会保存。
/music queue add <url> 追加一首曲目。
/music queue add <youtube-playlist-url> 展开播放列表并追加每首歌曲。
- 队列元数据在后台加载,因此新项目可能会短暂显示为
title loading。
- 以
- Topic 结尾的 YouTube 创作者名称将不带该后缀显示。
- 如果元数据获取失败,URL 仍将保留在队列中,播放仍会尝试播放它。
示例输出:
[Music] Queue:
1. Song Title - Creator Name | 3:22 | requested by PlayerName | added 16:21:05
2. title loading: | requested by PlayerName
已保存播放列表
所有玩家:
/music playlist list
/music playlist create <name>
/music playlist delete <name>
/music playlist show <name>
/music playlist add <name> <url>
/music playlist remove <name> <index>
/music playlist play <name>
/music playlist queue <name>
播放列表行为:
- 播放列表保存在
config/music-playlists.json 中。
- 播放列表名称为单个单词。
/music playlist add <name> <url> 添加一首曲目。
/music playlist add <name> <youtube-playlist-url> 导入 YouTube 播放列表中的所有歌曲。
/music playlist play <name> 替换当前播放并开始播放列表。
/music playlist queue <name> 将已保存的播放列表追加到当前队列之后。
示例:
/music playlist create lobby
/music playlist add lobby
/music playlist add lobby
/music playlist play lobby
定向
/music target all
/music target only <players>
/music target add <players>
/music target remove <players>
/music target show
/music exclude add <players>
/music exclude remove <players>
/music exclude clear
目标顺序:
- 已连接的 Simple Voice Chat 客户端。
- 如果设置了包含过滤器,则优先匹配。
- 排除过滤器。
- 玩家通过
/music leave 进行的个人退出设置。
个人退出设置始终具有最高优先级。/music target all 不会强制让已退出的玩家收听。
示例:
/music target all
/music target only Steve
/music target add Alex
/music exclude add Steve
/music exclude clear
配置文件
主配置文件:
config/music.json
存储 YouTube OAuth 设置、重复/随机播放设置、目标过滤器、排除项以及玩家退出设置。
播放列表配置文件:
config/music-playlists.json
存储已保存的播放列表名称和曲目条目。
示例播放列表结构:
{
"playlists": {
"lobby": [
{
"url": "https://www.youtube.com/watch?v=SONG_1",
"title": "歌曲标题",
"creator": "创作者名称",
"requestedByName": "服务器",
"durationMillis": 202000
}
]
}
}
在服务器运行时,请使用命令而非直接编辑播放列表文件。
URL 支持
推荐使用的链接类型:
- 普通 YouTube 观看链接。
- YouTube Music 观看链接。
- YouTube 和 YouTube Music 播放列表链接。
- Lavaplayer 支持的直接音频文件 URL。
- 部分可提取音频的直接视频 URL。
可靠性较低的链接类型:
- Spotify 页面链接。
- 私密或受年龄限制的视频。
- 地区封锁视频。
- 被机器人检测拦截的 YouTube 链接。
不支持的 URL 应通过聊天错误提示失败,而不是导致服务器崩溃。
命令访问权限
所有玩家都可以使用所有的 /music 命令,包括更改服务器播放状态的命令:
- 播放、停止、暂停、恢复、跳过、快进、后退。
- 队列添加/移除/清空。
- 播放列表创建/删除/添加/移除/播放/入列。
- 目标与排除过滤器。
- 循环、随机、全局音量。
自助与查看命令:
/music help
/music now
/music queue list
/music leave
/music join
故障排除
音乐显示正在播放,但无人听到
运行:
/music now
/music target show
检查:
- Simple Voice Chat 已连接。
- 语音目标/监听者数量不为
0。
- 玩家未执行
/music leave。
- 玩家未被
/music exclude 排除。
- 客户端 Simple Voice Chat 的“音乐”滑块未处于
0%。
- 全局音量没有过低。
YouTube 提示登录或机器人验证
在 config/music.json 中启用 OAuth,重启后运行:
/music play <youtube-url>
完成服务器日志中显示的设备和登录步骤。此后,youtubeOAuthRefreshToken 将被保存。
队列名称显示为加载中或未知
元数据是异步加载的。等待几秒后运行:
/music queue list
如果元数据仍显示为未知,则 Lavaplayer 无法解析该 URL 的元数据。当轮到该曲目时,模组仍会尝试播放该 URL。
所有目标设置后,某玩家听不到音乐
检查该玩家是否选择了退出:
/music target show
该玩家可以通过以下方式重新加入:
/music join
个人退出选项优先于目标过滤器。
备注
- 此模组不会将歌曲下载到磁盘。
- 如果 YouTube 屏蔽了客户端或更改了播放器行为,YouTube 播放仍可能失败。
- YouTube 主题频道的作者名称在显示时会被清理;例如,
Artist - Topic 会变为 Artist。
- OAuth 可提升 YouTube 的可靠性,但建议使用辅助的 YouTube 账号。
- 服务端未实现按玩家独立的音量控制;请使用 Simple Voice Chat 客户端中的“Music”滑块来调节个人音量。
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
- Install Fabric Loader on the server.
- Install Simple Voice Chat on the server.
- Install this mod in the server
mods folder.
- Players who want to hear the stream must install Simple Voice Chat on their clients.
- Start the server and run
/music help.
Quick Start
/music now
/music play 10
/music queue add
/music queue add
/music queue list
If YouTube asks for login or blocks playback, complete the OAuth device login shown in the server log.
How It Works
- A player runs
/music play, queues a URL, or starts a saved playlist.
- Lavaplayer loads the URL.
- YouTube links are handled by
youtube-source.
- The mod sends encoded audio frames into a Simple Voice Chat static audio channel.
- 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:
config/music.json
Important fields:
{
"youtubeOAuthEnabled": true,
"youtubeOAuthRefreshToken": "",
"youtubeOAuthSkipInitialization": false
}
First login flow:
- Start the server.
- Run
/music play <youtube-url>.
- Check the server log for the Google device login code.
- Complete the login in a browser.
- 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:
/music help
/music help queue
/music help playlist
/music help target
/music help volume
Everyone
/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:
/music play <url>
/music play <url> <volume>
/music stop
/music pause
/music resume
/music skip
/music forward <seconds>
/music backward <seconds>
/music volume <1-100>
/music repeat off
/music repeat one
/music repeat queue
/music shuffle on
/music shuffle off
Behavior:
/music play <url> starts immediately and clears the runtime queue.
/music play <youtube-playlist-url> starts the first playlist track and queues the rest.
/music play <url> <volume> starts playback and sets global volume from 1 to 100.
/music forward <seconds> seeks ahead in the current track.
/music backward <seconds> 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:
/music queue add <url>
/music queue remove <index>
/music queue clear
/music skip
Everyone can view:
/music queue list
Queue behavior:
- The runtime queue is not saved after server restart.
/music queue add <url> appends a track.
/music queue add <youtube-playlist-url> 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:
[Music] Queue:
1. Song Title - Creator Name | 3:22 | requested by PlayerName | added 16:21:05
2. title loading: | requested by PlayerName
Saved Playlists
All players:
/music playlist list
/music playlist create <name>
/music playlist delete <name>
/music playlist show <name>
/music playlist add <name> <url>
/music playlist remove <name> <index>
/music playlist play <name>
/music playlist queue <name>
Playlist behavior:
- Playlists are saved in
config/music-playlists.json.
- Playlist names are single words.
/music playlist add <name> <url> adds one track.
/music playlist add <name> <youtube-playlist-url> imports every song from the YouTube playlist.
/music playlist play <name> replaces current playback and starts the playlist.
/music playlist queue <name> appends the saved playlist after the current queue.
Example:
/music playlist create lobby
/music playlist add lobby
/music playlist add lobby
/music playlist play lobby
Targeting
All players:
/music target all
/music target only <players>
/music target add <players>
/music target remove <players>
/music target show
/music exclude add <players>
/music exclude remove <players>
/music exclude clear
Targeting order:
- Connected Simple Voice Chat clients.
- Include filter if set.
- Exclude filter.
- Player personal opt-out from
/music leave.
Personal opt-out always wins. /music target all does not force opted-out players to listen.
Examples:
/music target all
/music target only Steve
/music target add Alex
/music exclude add Steve
/music exclude clear
Config Files
Main config:
config/music.json
Stores YouTube OAuth settings, repeat/shuffle settings, target filters, exclusions, and player opt-outs.
Playlist config:
config/music-playlists.json
Stores saved playlist names and track entries.
Example playlist shape:
{
"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:
/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:
/music play <youtube-url>
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:
/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:
/music target show
The player can rejoin with:
/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.
评论 0
登录后参与评分
还没有评论,来抢沙发吧