Python Forum
[PyGame] Play Audio While continuing Gameplay
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Play Audio While continuing Gameplay
#1
I am new to game development.

I am making Snake game as my first game project. I want to play audio when snake eats food.

I tried doing using this:

from playsound import playsound
playsound("D:/Projects/Pygame/food.mp3")
When Snake eats food, sound is played but game freezes until sound is finished. How do i play sound and also continue gameplay at sametime? Do I need to use threading?
Reply
#2
If you're using pygame for graphics, you should also use it for sound: https://www.pygame.org/docs/ref/mixer.ht...ixer.Sound
Reply
#3
See the following forum thread
https://python-forum.io/Thread-PyGUI-pyg...o-anything
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I can not play mp3 in pygame vinicius 4 5,138 Feb-19-2018, 11:01 PM
Last Post: SeabassG33

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020