When i run the code it play only the .wav file
import pygame, sys
from pygame.locals import *
pygame.init()
DISPLAYSURF = pygame.display.set_mode((500, 400), 0, 32)
pygame.mixer.music.load('background.ogg')
pygame.mixer.music.play()
soundObj = pygame.mixer.Sound('bird.wav')
soundObj.play()
pygame.mixer.music.stop()
someone know what i should do for the background.ogg to be played too?
Remove this line:
Basically, you're loading and playing the background noise, and then immediately stopping it. I also suggest you create a
main loop
, like so:Most of the time people just check if
Escape
was pressed in their main loop (if it was pressed, they setrunning = False
and exit the program).