mpv-discordRPC 项目教程
1. 项目目录结构及介绍
mpv-discordRPC/
├── assets/
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ └── 4.png
├── bin/
│ └── mpv-discord
├── script-opts/
│ └── discord.conf
├── scripts/
│ └── discord.lua
├── .gitignore
├── LICENSE.txt
├── README.md
├── install_darwin.sh
├── install_linux.sh
└── install_windows.bat
目录结构介绍
- assets/: 包含项目所需的图像资源文件。
- bin/: 包含项目的二进制文件
mpv-discord
,这是插件的后端二进制文件。 - script-opts/: 包含项目的配置文件
discord.conf
。 - scripts/: 包含项目的用户脚本文件
discord.lua
。 - .gitignore: Git 忽略文件列表。
- LICENSE.txt: 项目的 MIT 许可证文件。
- README.md: 项目的说明文档。
- install_darwin.sh: macOS 系统的安装脚本。
- install_linux.sh: Linux 系统的安装脚本。
- install_windows.bat: Windows 系统的安装脚本。
2. 项目启动文件介绍
scripts/discord.lua
discord.lua
是 mpv 的用户脚本文件,当 mpv 启动时,它会运行所有用户脚本,包括 discord.lua
。discord.lua
的主要功能如下:
- 读取配置文件:
discord.lua
会从script-opts/discord.conf
读取配置。 - 创建输入 IPC 服务器: 创建一个
input-ipc-server
套接字。 - 启动子进程: 启动
mpv-discord
二进制文件的子进程。
bin/mpv-discord
mpv-discord
是插件的后端二进制文件,它与 input-ipc-server
交互以获取 mpv 的播放器状态和属性,并通过 Discord 的 IPC 套接字更新 Discord 的 Rich Presence。
3. 项目的配置文件介绍
script-opts/discord.conf
discord.conf
是项目的配置文件,用户可以通过编辑此文件来定制 Discord Rich Presence 的行为。主要配置项包括:
- client_id: 设置 Discord 开发者门户中创建的应用程序 ID。
- 图像资源: 配置文件中可以指定不同的图像资源,如
play
、pause
、loop
和buffer
,用于在不同的播放状态下显示。
配置示例
client_id=834116350884577280
play=play
pause=pause
loop=loop
buffer=buffer
通过以上配置,用户可以自定义 Discord Rich Presence 的显示内容和样式。