pygame-ce
pygame-ce copied to clipboard
No such device error when initializing mixer module
trafficstars
When I'm trying to play some audio via choosed input device (virtual audio cable) I'm getting an error: 'pygame.error: No such device.' despite the fact that the device is in the list. The same thing happens when I pass the name of the first device (index 0). When I'm trying to do same thing when I'm passing False value everything works fine. Few days ago selecting an input device worked without throwing any error.
Source:
from pygame._sdl2.audio import get_audio_device_names
from pygame import mixer
import pygame
pygame.init()
devices = get_audio_device_names(True)
print(devices)
file_path = "sounds/some-short-file.mp3"
mixer.quit()
mixer.init(devicename = devices[1])
mixer.music.load(file_path)
mixer.music.play()
Output:
pygame-ce 2.5.1 (SDL 2.30.6, Python 3.12.1)
['Microphone (Realtek(R) Audio)', 'CABLE Output (VB-Audio Virtual Cable)']
Traceback (most recent call last):
File "D:\t.py", line 10, in <module>
mixer.init(devicename = devices[1])
pygame.error: No such device.
Process finished with exit code 1