On a clean install of Raspbian Jessie I want to play mp3s via mplayer through my Sabrent USB Audio driver. On Raspbian itself this was plug n' play; I changed the default audio device to "USB Audio Device" and then Youtube etc. worked as desired. In the CLI,
mplayer myfile.mp3
also worked perfectly. But in Python (3.4), the audio keeps funneling through HDMI to my monitor's speakers. This happens even when I switch my Python mp3 player to pygame, so it seems to be an issue with RasPi settings / Python.
Edit: When I changed the default audio device, I did so through the Jessie desktop interface in Preferences / Audio Device Settings. That window lists "USB Audio Device (Alsa mixer)" as default, as desired.
pygame.mixer.init()
? Edited the question with another env. var. too. – Technico.top Jun 08 '17 at 00:14cat /proc/asound/cards
to get hardware codes, then usedexport SDL_AUDIODEV=hw:1,0
to set priority, but problem persisted. Seems to be independent of python -- from CLI just triedsudo mplayer myfile.mp3
and it comes through HDMI. – Twiffy Jun 08 '17 at 01:00print(os.getenv('SDL_AUDIODRIVER'))
andprint(os.getenv('SDL_AUDIODEV'))
to verify that these variables are correct on the program context. – Technico.top Jun 08 '17 at 01:09