获取vlc中的输出设备名称

Get the output device name in vlc

我想在vlc 中获取输出设备的名称。我使用 audio_output_device_enum 函数,但它没有给我主输出设备的名称 我的代码:

import vlc
p=vlc.MediaPlayer("music.mp3")
mods = p.audio_output_device_enum()
if mods:
    devices=[]
    mod = mods
    while mod:
        mod = mod.contents
        devices.append(mod.device)
        mod = mod.next
print(devices[1])

b'{0.0.0.00000000}.{152df11f-ed40-403e-8bf6-7916e2b74849}'

虽然我想告诉我原来的名字,Speakers (High Definition Audio)。 如何找到原始输出设备名称? 谢谢。

audio_output_device_enum 除了 device
还包含 description 注意事项 audio_output_device_enum:

   @note: Not all audio outputs support enumerating devices.
   The audio output may be functional even if the list is empty (None).
   @note: The list may not be exhaustive.
   @warning: Some audio output devices in the list might not actually work in
   some circumstances.
import vlc
import time

p=vlc.MediaPlayer("vp.mp3")
mods = p.audio_output_device_enum()
if mods:
    devices=[]
    mod = mods
    while mod:
        mod = mod.contents
        devices.append([mod.device,mod.description])
        mod = mod.next
for d in devices:
    print(d)
p.play()
time.sleep(1)
while p.is_playing():
    time.sleep(1)

输出:

[b'alsa_output.pci-0000_00_1b.0.analog-stereo', b'Built-in Audio Analogue Stereo']