2021-10-12 19:45:29 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"
|
|
|
|
os.putenv('SDL_AUDIODRIVER', 'pulseaudio')
|
|
|
|
import pygame._sdl2 as sdl2
|
|
|
|
import pygame
|
|
|
|
from pygame import mixer
|
2021-11-02 22:48:52 +00:00
|
|
|
pygame.init()
|
2021-10-12 19:45:29 +00:00
|
|
|
import time
|
|
|
|
mixer.init(44100, -16, 2, 1024)
|
|
|
|
is_capture = 0 # zero to request playback devices, non-zero to request recording devices
|
|
|
|
num = sdl2.get_num_audio_devices(is_capture)
|
|
|
|
names = [str(sdl2.get_audio_device_name(i, is_capture), encoding="utf-8") for i in range(num)]
|
|
|
|
mixer.quit()
|
|
|
|
for i in names:
|
|
|
|
print(i)
|
|
|
|
mixer.init(44100, -16, 2, 1024, devicename=i)
|
|
|
|
print(mixer.get_init())
|
|
|
|
mixer.music.load("/home/mstratford/Downloads/managed_play.mp3")
|
|
|
|
mixer.music.play()
|
2021-11-02 23:02:09 +00:00
|
|
|
# my_song = mixer.Sound("/home/mstratford/Downloads/managed_play.mp3")
|
|
|
|
# my_song.play()
|
2021-10-12 19:45:29 +00:00
|
|
|
time.sleep(5)
|
2021-11-02 23:02:09 +00:00
|
|
|
pygame.quit()
|