【发布时间】:2022-11-18 01:25:59
【问题描述】:
我正在尝试检索可用 AirPlay 输出音频设备的列表,但我对使用哪种语言没有偏好。
在 Ventura 之前,我使用了以下 Apple 脚本:
set devices to {}
tell application "System Preferences"
reveal pane id "com.apple.preference.sound"
end tell
tell application "System Events"
tell application process "System Preferences"
repeat until exists tab group 1 of window "Sound"
end repeat
tell tab group 1 of window "Sound"
click radio button "Output"
tell table 1 of scroll area 1
set selected_row to (first UI element whose selected is true)
set currentOutput to value of text field 1 of selected_row as text
repeat with r in rows
try
set deviceName to value of text field 1 of r as text
set deviceType to value of text field 2 of r as text
set end of devices to { deviceName, deviceType }
end try
end repeat
end tell
end tell
end tell
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
return [ devices, "currentOutput", currentOutput ]
但自从 Ventura 更新后,这个问题似乎就没有办法让它适应 Apple Script 了。
有谁知道如何更新它以与 Ventura 一起使用,或者可以指出 Swift 或 ObjC 的文档来检索此列表?
【问题讨论】:
-
我只用过它德比安, 绝不苹果系统并且完全不知道它是否适合你,或者它是否在正确的方向上,但如果我使用
avahimDNS 服务发现,我的 SONOS 扬声器显示为 AirPlay 设备。它似乎在 macPorts ports.macports.org/port/avahi YMMV 上,只是想提供帮助。