MprisCustomHud
重要信息
描述
为 CustomHud 和 Hudder 提供变量,通过 Mpris DBus 规范显示当前正在播放的音乐。
适用于所有 CustomHud v4 支持的版本!
在 Minecraft 1.21.9/10 和 1.21.11/26.1.x 版本中,分别兼容 Hudder 8.x、9.x 以及 10.x 版本。
本模组深受 Hudify 的启发,因此感谢 Lightningtow 的工作成果 :)
注意
通用变量
| 名称 |
类型 |
描述 |
mpris_busname |
String |
busname |
mpris_track |
String |
曲目名称 |
mpris_trackid |
String |
唯一的 mpris 曲目 ID(主要用于调试) |
mpris_album |
String |
该曲目所属的专辑名称 |
mpris_repeat |
String |
重复状态 - "None"、"Track" 或 "Playlist" |
mpris_artist |
String |
来自 mpris 的第一个艺术家姓名 |
mpris_name |
String |
来自 org.mpris.MediaPlayer2 的 Identity 属性的精美播放器名称 |
mpris_lyrics |
String |
xesam:asText |
mpris_created_at |
String |
xesam:contentCreated |
mpris_first_played |
String |
xesam:firstUsed |
mpris_last_played |
String |
xesam:lastUsed |
mpris_art_url |
String |
xesam:artUrl |
mpris_url |
String |
xesam:url |
mpris_shuffle |
Boolean |
是否开启随机播放 |
mpris_playing |
Boolean |
歌曲是否正在播放或处于暂停/停止状态 |
mpris_exists |
Boolean |
当前曲目是真实曲目还是占位符 |
mpris_has_album_art |
Boolean |
曲目是否有专辑封面/是否已加载 |
mpris_data_age |
Number |
元数据信息(曲目、曲目 ID、专辑、艺术家、艺术家列表、时长等)的年龄,单位为毫秒 |
mpris_progress |
Number |
进度,单位为毫秒 |
mpris_duration |
Number |
曲目时长,单位为毫秒 |
mpris_rate |
Number |
音乐播放的速率/速度,以浮点数表示 |
mpris_volume |
Number |
音乐播放时的音量,以浮点数表示(通常在 0 到 1 之间) |
mpris_bpm |
Number |
xesam:audioBPM |
mpris_disc |
Number |
xesam:discNumber |
mpris_number |
Number |
xesam:trackNumber |
mpris_times_played |
Number |
xesam:useCount |
mpris_auto_rating |
Number |
xesam:autoRating |
mpris_user_rating |
Number |
xesam:userRating |
mpris_album_width |
Number |
专辑封面的绝对像素宽度 |
mpris_album_height |
Number |
专辑封面的绝对像素高度 |
mpris_album_color |
Number |
专辑封面主导颜色的 RGB 值 |
mpris_artists |
List of String |
当前播放器的艺术家列表 |
mpris_album_artists |
List of String |
当前播放器的 xesam:albumArtist |
mpris_comments |
List of String |
当前播放器的 xesam:comment |
mpris_composers |
List of String |
当前播放器的 xesam:composer |
mpris_genres |
List of String |
当前播放器的 xesam:genre |
mpris_lyricists |
List of String |
当前播放器的 xesam:lyricist |
CustomHud 特定内容
- 据我观察,将列表作为字段/属性并不方便,因此这里仅列出当前玩家的列表
- 所有 String 变量要么非空,要么为
null
- 列表默认使用前缀,该前缀由变量名中
mpris_ 之后的前四个字母组成(用于迭代)
- PlayerInfo 对象包含所有通用变量,以及移除
mpris_ 前缀后的 mpris_album_art 作为字段
| Name |
Type/Usage |
Description |
mpris_player |
{mpris_player:<field>} or {mpris_player:<player>:<field>} |
暴露 PlayerInfo 对象的字段;player 可以是完整的总线名称(busname),也可以是最后一部分 |
mpris_players |
List of PlayerInfo like Objects |
当前活跃的 PlayerInfo 对象列表(与上述相同的 <fields>) |
mpris_album_art |
Icon |
将当前播放器的专辑封面图像绘制到屏幕上 |
有关 xesam:<name> 和 mpris:<name> 变量的详细信息,请参阅 。
Hudder 特定内容
Variables
| Name |
Type |
Description |
has_mpris |
Boolean |
始终为 true |
mpris_player |
Object/PlayerInfo |
当前选中播放器的 PlayerInfo 对象,若未选中则为 null |
mpris_players |
List<PlayerInfo> |
当前跟踪的播放器列表 |
Functions/Methods
| Name |
Arguments |
Effect |
mpris_player |
String name |
返回总线名称为 org.mpris.MediaPlayer2.<name> 的 PlayerInfo 对象,若不存在则返回 null |
mpris_album_art |
String name or AlbumArt albumArt, int x, int y, int width, int height |
绘制专辑封面图像;如果曲目没有专辑封面,则绘制备用图像;如果 width 或 height 为 0,则保留原始宽高比;如果两者都为 0,则使用像素尺寸(太大了 lol) |
Objects
PlayerInfo:
String busname - 总线名称(busname)
String name - 播放器名称
String repeat - 重复状态 - 参见 mpris_repeat
boolean shuffle - 随机播放状态
boolean playing - 是否正在播放音乐
double rate - 音乐播放速率
double volume - 音乐音量(通常在 0 到 1 之间)
Metadata metadata - 元数据
long progress() - 返回当前进度(毫秒)
Metadata:
String track - 当前曲目 - xesam:title
String trackid - 当前曲目 ID - mpris:trackid
String album - 当前专辑 - xesam:album
String artist - 第一位艺术家
String art_url - mpris:artUrl
String lyrics - xesam:asText
String created_at - xesam:contentCreated
String first_played - xesam:firstUsed
String last_played - xesam:lastUsed
String url - xesam:url
List<String> artists - 所有艺术家 - xesam:artist
List<String> album_artists - xesam:albumArtist
List<String> comments - xesam:comment
List<String> composers - xesam:composer
List<String> genres - xesam:genre
List<String> lyricists - xesam:lyricist
int bpm - xesam:audioBPM
int disc - xesam:discNumber
int number - xesam:trackNumber
int times_played - xesam:useCount
float auto_rating - xesam:autoRating
float user_rating - xesam:userRating
long duration - 当前曲目的持续时间(毫秒)
AlbumArt album_art - 关于专辑封面的信息
long data_age() - 返回对象的年龄(毫秒)
AlbumArt:
int width - 宽度(像素)
int height - 高度(像素)
int color - 专辑封面主要颜色的 RGB 值
boolean exists() - 真实图像或备用图像的对应对象是否存在
Controls
有用于播放/暂停、下一首、上一首、刷新和循环切换活跃播放器的按键绑定,它们都有对应的命令。
Configuration
默认情况下,会从当前活跃的玩家中选择一个。要循环切换当前活跃的玩家,请使用 mpriscustomhud cycle 命令(仅在 onlyPreferred 禁用时生效,此为默认设置)。
你可以使用 mpriscustomhud preferred <player> 指定一个优先显示的玩家,这样只要该玩家处于活跃状态,就会始终显示他/她。
如果你不想看到其他玩家(仅显示优先指定的那一位),可以使用 mpriscustomhud onlyPreferred true。如果你未设置优先玩家,这将导致没有玩家被选中。
使用 mpriscustomhud player 可获取当前活跃的玩家;使用 mpriscustomhud onlyPreferred 和 mpriscustomhud preferred 可获取相应的配置值;使用 mpriscustomhud refresh 可刷新这些变量。
Flatpak 注意事项
- 当你在 Flatpak 沙箱环境中运行 Minecraft 时,你需要将
org.mpris.MediaPlayer2.* 添加到启动器可以通信的已知会话总线名称列表中,例如通过 Flatseal 进行配置。
问题/待办
目前尚无专辑封面变量;也许我稍后会尝试添加 已完成
使用的库
- dbus-java
- freedesktop.org 提供的 Java DBus 库的改进版本
许可证
本模组采用 MIT 许可证授权。
MprisCustomHud
Important
Description
Variables for CustomHud and Hudder to show currently playing music using the Mpris DBus Spec.
Available for all versions CustomHud v4 is available for!
Works with Hudder 8.x, 9.x on version 1.21.9/10 and 10.x for version 1.21.11/26.1.x
It is heavily inspired by Hudify, so thank you for your work Lightningtow ig :)
Note
- Not all variables have to be/will be populated by the player/music application
General Variables
| Name |
Type |
Description |
mpris_busname |
String |
busname |
mpris_track |
String |
track name |
mpris_trackid |
String |
the unique mpris track id (mostly for debugging) |
mpris_album |
String |
name of the album the track is from |
mpris_repeat |
String |
repeat status - "None", "Track" or "Playlist" |
mpris_artist |
String |
name of the first artist coming from mpris |
mpris_name |
String |
the pretty player name from the Identity attribute of org.mpris.MediaPlayer2 |
mpris_lyrics |
String |
xesam:asText |
mpris_created_at |
String |
xesam:contentCreated |
mpris_first_played |
String |
xesam:firstUsed |
mpris_last_played |
String |
xesam:lastUsed |
mpris_art_url |
String |
xesam:artUrl |
mpris_url |
String |
xesam:url |
mpris_shuffle |
Boolean |
wether shuffle is on |
mpris_playing |
Boolean |
wether the song is playing or paused/stopped |
mpris_exists |
Boolean |
wether the current track is real or a placeholder |
mpris_has_album_art |
Boolean |
wether the track has an album art/it is loaded |
mpris_data_age |
Number |
the age of the metadata information (track, trackid, album, artist, artists, duration, ...) in milliseconds |
mpris_progress |
Number |
progress in milliseconds |
mpris_duration |
Number |
duration of the track in milliseconds |
mpris_rate |
Number |
the rate/speed the music is playing as floating point number |
mpris_volume |
Number |
the volume the music is playing at as a floating point number (usually between 0 and 1) |
mpris_bpm |
Number |
xesam:audioBPM |
mpris_disc |
Number |
xesam:discNumber |
mpris_number |
Number |
xesam:trackNumber |
mpris_times_played |
Number |
xesam:useCount |
mpris_auto_rating |
Number |
xesam:autoRating |
mpris_user_rating |
Number |
xesam:userRating |
mpris_album_width |
Number |
the absolute pixel width of the album art |
mpris_album_height |
Number |
the absolute pixel height of the album art |
mpris_album_color |
Number |
the rgb value of the dominant color of the album art |
mpris_artists |
List of String |
list of artists for the current player |
mpris_album_artists |
List of String |
xesam:albumArtist for the current player |
mpris_comments |
List of String |
xesam:comment for the current player |
mpris_composers |
List of String |
xesam:composer for the current player |
mpris_genres |
List of String |
xesam:genre for the current player |
mpris_lyricists |
List of String |
xesam:lyricist for the current player |
CustomHud specific things
- From what I can tell, it is not easily possible to have a list as a field/attribte so here are only the lists for the current player
- All String variables are either not empty or
null
- Lists have the the first four letters of the variable name after
mpris_ as the default prefix (for iteration)
- PlayerInfo objects have all general variables +
mpris_album_art with the mpris_ prefix removed as fields
| Name |
Type/Usage |
Description |
mpris_player |
{mpris_player:<field>} or {mpris_player:<player>:<field>} |
exposes the fields of a PlayerInfo Object; player can be the full busname or only the last part |
mpris_players |
List of PlayerInfo like Objects |
just a list of currently active PlayerInfo Objects (same <fields> as above) |
mpris_album_art |
Icon |
draws the album art image of the current player to the screen |
See for details on the xesam:<name> and mpris:<name> variables.
Hudder specific things
Variables
| Name |
Type |
Description |
has_mpris |
Boolean |
always true |
mpris_player |
Object/PlayerInfo |
the PlayerInfo object of the currently selected player or null |
mpris_players |
List<PlayerInfo> |
a list of currently tracked players |
Functions/Methods
| Name |
Arguments |
Effect |
mpris_player |
String name |
returns the PlayerInfo object with the bus name org.mpris.MediaPlayer2.<name> or null |
mpris_album_art |
String name or AlbumArt albumArt, int x, int y, int width, int height |
draws the album art image; if the track has no album art, it draws a fallback; if width or height is 0 it will retain the original aspect ratio; if both are 0, it will use the pixel dimensions (way too big lol) |
Objects
PlayerInfo:
String busname - the busname
String name - player name
String repeat - repeat status - see mpris_repeat
boolean shuffle - shuffle status
boolean playing - wether music is playing
double rate - the rate the music is playing at
double volume - the volume the music is playing at (usually between 0 and 1)
Metadata metadata - metadata
long progress() - returns the current progress (in ms)
Metadata:
String track - current track - xesam:title
String trackid - current track id - mpris:trackid
String album - current album - xesam:album
String artist - first artist
String art_url - mpris:artUrl
String lyrics - xesam:asText
String created_at - xesam:contentCreated
String first_played - xesam:firstUsed
String last_played - xesam:lastUsed
String url - xesam:url
List<String> artists - all artists - xesam:artist
List<String> album_artists - xesam:albumArtist
List<String> comments - xesam:comment
List<String> composers - xesam:composer
List<String> genres - xesam:genre
List<String> lyricists - xesam:lyricist
int bpm - xesam:audioBPM
int disc - xesam:discNumber
int number - xesam:trackNumber
int times_played - xesam:useCount
float auto_rating - xesam:autoRating
float user_rating - xesam:userRating
long duration - duration of current track (in ms)
AlbumArt album_art - information on the album art
long data_age() - returns the age of the object (in ms)
AlbumArt:
int width - width in pixels
int height - height in pixels
int color - the rgb value of the dominant color of the album art
boolean exists() - wether the object for the real image or the fallback one
Controls
There are keybindings for play/pause, next, previous, refresh and cycle through active players that all have correcsponding commands.
Configuration
By default a player is selected from the active ones. To cycle through the currently active ones, use the mpriscustomhud cycle command (only works onlyPreferred is disabled (default)).
You can choose a player to prefer over others by using mpriscustomhud preferred <player> so that one will always be shown if it's active.
If you don't want to see other players (only the preferred one), you can use mpriscustomhud onlyPreferred true. This will result in no player being selected if you didn't set a preferred one.
With mpriscustomhud player, you get the currently active player, with mpriscustomhud onlyPreferred and mpriscustomhud preferred the values for that and with mpriscustomhud refresh, you can refresh the variables.
Flatpak notice
- when you're running Minecraft in a Flatpak sandbox, you have to add
org.mpris.MediaPlayer2.* to the list of well known session bus names your launcher can talk to e.g. with Flatseal
Problems/Todo
currently there is no album art variable; maybe I will try to add it at some point done
Libraries used
- dbus-java
- Improved version of java DBus library provided by freedesktop.org
License
This Mod is licensed under the MIT License
评论 0
登录后参与评分
还没有评论,来抢沙发吧