Control Apple TV, HomePod, and AirPlay devices via pyatv (scan, stream, playback, volume, navigation).
使用atvremote从命令行控制Apple TV、HomePod和AirPlay设备。
bash
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
bash
atvremote -n Kitchen
atvremote -s 10.0.0.50
atvremote -i AA:BB:CC:DD:EE:FF
bash
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 # 随机播放:关闭、歌曲、专辑
atvremote -n Kitchen set_repeat=All # 重复模式:关闭、单曲、全部
bash
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流式传输到设备:
bash
atvremote -n Kitchen stream_file=/path/to/audio.mp3 # 本地文件
atvremote -n Kitchen play_url=http://example.com/stream.mp3 # 远程URL
支持常见音频格式(MP3、WAV、AAC、FLAC等)。
bash
atvremote -n Apple TV power_state # 检查电源状态
atvremote -n Apple TV turn_on # 唤醒设备
atvremote -n Apple TV turn_off # 使设备休眠
bash
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 # 启动屏幕保护
当文本输入框获得焦点时:
bash
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 # 清除文本
bash
atvremote -n Apple TV app_list # 列出已安装应用
atvremote -n Apple TV launch_app=com.apple.TVMusic # 通过Bundle ID或URL启动应用
管理连接的音频输出(例如,组合HomePod):
bash
atvremote -n Apple TV output_devices # 列出当前输出设备ID
atvremote -n Apple TV addoutputdevices=
atvremote -n Apple TV removeoutputdevices=
atvremote -n Apple TV setoutputdevices=
实时监控播放变化:
bash
atvremote -n Kitchen push_updates # 实时打印更新(按ENTER停止)
某些设备(尤其是Apple TV)在控制前需要配对:
bash
atvremote -n Living Room pair # 配对(按照PIN码提示操作)
atvremote -n Living Room --protocol airplay pair # 配对特定协议
atvremote wizard # 交互式引导设置
配对后,凭据会自动存储在~/.pyatv.conf中。
bash
atvremote -n Kitchen device_info # 型号、操作系统版本、MAC地址
atvremote -n Kitchen features # 列出所有支持的功能
atvremote -n Kitchen app # 当前播放媒体的应用
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 apple-media-1776379789 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 apple-media-1776379789 技能
skillhub install apple-media-1776379789
文件大小: 2.95 KB | 发布时间: 2026-4-17 15:41