I have made a simple game that I want to add sound effects to. I have the short clips and can get them
to work with the following command:
It plays fine, but the problem is that it plays the file(s) with windows media player: effectively
taking the "focus" away from the main tk window (or any window associated with the game, for
This is a problem because it takes away from the "flow/cohesion" of the game. I could just click
back on the tk window and resume playing, but I have spent a good amount of time enabling key
controls in my game(You can play the whole game with only the keyboard).
When each sound effect is played, the focused window is windows media player and whatever
keyboard input that is received is assigned to the newly opened program. Does anyone have any
solution of what I could do to address this?
I have identified several possible approches for a solution:
(1) Use Python modules for sound (e.g. winsound)
(2) Create multiple threads
(3) Search for method(s) on how to refocus the window (e.g. "window.grab_set()" method..??)
(4) Several program can be implemented (e.g. Pymedia, Pygame, PyAudio, Pyglet, etc.)
I think one of the main focuses here is that I may/may not want to use an external library for
sound playing? How could I embed these sound files(mostly .mp3, some .wav) in my program
without running a separate program to play them?
Any thoughts from personal experience and/or subjects that you can refer me to study up on
would be greatly appreciated, thanks.
This topic is now closed. New replies are no longer allowed.