mixmastamyk / boombox

A simple cross-platform audio-file player module for Python.
GNU Lesser General Public License v3.0
12 stars 0 forks source link

Boombox not playing sounds on Windows #2

Closed Bertik23 closed 4 years ago

Bertik23 commented 4 years ago

Hi I have made a program called Drink! on Linux and I assumed it would work on Windows as well, but when I run it on Windows I can't hear anything. So I ran python -m boombox to test it and got this result

DEBUG <module>:533 boombox version: 0.56
INFO <module>:540 Playing media:… 'c:/Windows/Media/Alarm08.wav'
DEBUG __init__:74 initializing WinBoomBox
DEBUG __init__:86 audio is a filename to load: 'c:/Windows/Media/Alarm08.wav'
DEBUG verify_file:55 verified: 'c:/Windows/Media/Alarm08.wav'
DEBUG play:99 playing: 'c:/Windows/Media/Alarm08.wav'
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\alber\AppData\Roaming\Python\Python37\site-packages\boombox.py", line 542, in <module>
    _boombox.play()
  File "C:\Users\alber\AppData\Roaming\Python\Python37\site-packages\boombox.py", line 100, in play
    self._player.PlaySound(self._sound_file, self._flags)
RuntimeError: Failed to play sound
mixmastamyk commented 4 years ago

Hmm, hard to say. I suppose I would try the winsound module directly to see what happens.

https://docs.python.org/3/library/winsound.html

 winsound.PlaySound(soundfile, flags)

Does it have a runtime error as well? If so the audio device is borked, else the flags field might not be correct. I've added a log line in my copy to print it out. Here's how to do it externally, printing the flag constants might shed some light:

print(boombox._flags, winsound.SND_FILENAME)

If the audio device works, trying PyAudio might yield some clues as well. It prints a lot of debug information (that boombox silences) if you use it on its own

Bertik23 commented 4 years ago

Well, that is wierd. I haven't done anything and now it works.