运行时依赖
安装命令
点击复制技能文档
Apple Media Remote Control 使用 atvremote 从命令行控制 Apple TV、HomePod 和 AirPlay 设备。
安装说明 pyatv 与 Python 3.14+ 存在兼容性问题。安装时使用 --python python3.13(或任何版本 ≤3.13)。 如果 ~/.local/bin 不在 PATH 中,安装后运行:pipx ensurepath 如果默认 Python 版本为 3.14+,也可以直接调用:python3.13 -m pyatv.scripts.atvremote
扫描设备 atvremote scan atvremote --scan-hosts 10.0.0.50 scan # 扫描特定 IP(更快) atvremote --scan-hosts 10.0.0.50,10.0.0.51 scan # 扫描多个 IP
返回所有可发现的 Apple TV、HomePod 和 AirPlay 设备的名称、地址、协议和配对状态。
目标设备 使用 -n (设备名称)、-s (地址)或 -i (标识符)来目标: atvremote -n "Kitchen" atvremote -s 10.0.0.50 atvremote -i AA:BB:CC:DD:EE:FF
播放控制 atvremote -n "Kitchen" playing # 正在播放的信息(标题、艺术家、专辑、位置等) atvremote -n "Kitchen" play # 恢复播放 atvremote -n "Kitchen" pause # 暂停播放(可以使用 play 恢复) atvremote -n "Kitchen" play_pause # 切换播放/暂停 atvremote -n "Kitchen" stop # 停止播放(结束会话,无法恢复) atvremote -n "Kitchen" next # 下一曲 atvremote -n "Kitchen" previous # 上一曲 atvremote -n "Kitchen" skip_forward # 跳过前进(约 10-30 秒,取决于应用程序) atvremote -n "Kitchen" skip_backward # 跳过后退(约 10-30 秒,取决于应用程序) atvremote -n "Kitchen" skip_forward=30 # 跳过前进特定秒数 atvremote -n "Kitchen" set_position=120 # 跳转到位置(秒) atvremote -n "Kitchen" set_shuffle=Songs # 随机播放:Off、Songs、Albums atvremote -n "Kitchen" set_repeat=All # 重复:Off、Track、All
音量 atvremote -n "Kitchen" volume # 获取当前音量(0-100) atvremote -n "Kitchen" set_volume=50 # 设置音量(0-100) atvremote -n "Kitchen" volume_up # 增加音量(约 2.5%) atvremote -n "Kitchen" volume_down # 减少音量(约 2.5%)
流媒体 将本地文件或 URL 流式传输到设备: atvremote -n "Kitchen" stream_file=/path/to/audio.mp3 # 本地文件 atvremote -n "Kitchen" play_url=http://example.com/stream.mp3 # 远程 URL 支持常见的音频格式(MP3、WAV、AAC、FLAC 等)。
电源管理 atvremote -n "Apple TV" power_state # 检查电源状态 atvremote -n "Apple TV" turn_on # 唤醒设备 atvremote -n "Apple TV" turn_off # 使设备睡眠
导航(Apple TV) atvremote -n "Apple TV" up # 方向键上 atvremote -n "Apple TV" down # 方向键下 atvremote -n "Apple TV" left # 方向键左 atvremote -n "Apple TV" right # 方向键右 atvremote -n "Apple TV" select # 按下选择/进入 atvremote -n "Apple TV" menu # 后退/菜单按钮 atvremote -n "Apple TV" home # 主页按钮 atvremote -n "Apple TV" home_hold # 长按主页(应用切换器) atvremote -n "Apple TV" top_menu # 进入主菜单 atvremote -n "Apple TV" control_center # 打开控制中心 atvremote -n "Apple TV" guide # 显示 EPG/指南 atvremote -n "Apple TV" channel_up # 下一个频道 atvremote -n "Apple TV" channel_down # 上一个频道 atvremote -n "Apple TV" screensaver # 激活屏幕保护
键盘输入(Apple TV) 当文本字段聚焦时: atvremote -n "Apple TV" text_get # 获取当前文本 atvremote -n "Apple TV" text_set="search query" # 替换文本 atvremote -n "Apple TV" text_append=" more" # 附加文本 atvremote -n "Apple TV" text_clear # 清除文本
应用控制(Apple TV) atvremote -n "Apple TV" app_list # 列出已安装的应用程序 atvremote -n "Apple TV" launch_app=com.apple.TVMusic # 按包 ID 或 URL 启动
输出设备(多房间) 管理连接的音频输出(例如,将 HomePods 分组): atvremote -n "Apple TV" output_devices # 列出当前输出设备 ID atvremote -n "Apple TV" add_output_devices= # 将扬声器添加到组 atvremote -n "Apple TV" remove_output_devices= # 从组中删除 atvremote -n "Apple TV" set_output_devices= # 设置特定输出
推送更新(实时监控) 监视实时播放更改: atvremote -n "Kitchen" push_updates # 打印更新(按 ENTER 停止)
配对 一些设备(尤其是 Apple TV)需要在控制之前配对: atvremote -n "Living Room" pair # 配对(遵循 PIN 提示) atvremote -n "Living Room" --protocol airplay pair # 配对特定协议 atvremote wizard # 交互式引导设置
凭证将在配对后自动存储在 ~/.pyatv.conf 中。
设备信息 atvremote -n "Kitchen" device_info # 型号、OS 版本、M