I have two files (sounds.py and game.py), I load my music in sounds.py using the following
import pygame
import os
main_dir = os.path.split(os.path.abspath(__file__))[0]
def load_music(folder, file):
"loads music, prepares it for play"
file = os.path.join(main_dir, folder, file)
try:
music = pygame.mixer.music.load(file)
except pygame.error:
raise SystemExit('Could not load music "%s" %s'%(file, pygame.get_error()))
return music
def add_queue(folder, file):
"loads music, adds it to queue"
file = os.path.join(main_dir, folder, file)
try:
music = pygame.mixer.music.queue(file)
except pygame.error:
raise SystemExit('Could not load music "%s" %s'%(file, pygame.get_error()))
return music
music = load_music('data/music', 'mm.wav')
msic2 = add_queue('data/music', 'mm2.wav')
In game.py I initialize the sound mixer with this
pygame.mixer.pre_init( 22050, -16, 2, 512 ) pygame.mixer.init()
and I also import sounds here. Further on I play the sound on startup using
def load_menu():
create_background(screen_size[0], screen_size[1], images.menu_tile, (0, 0))
if pygame.mixer.music.get_busy():
pygame.mixer.music.set_volume(1.0)
else:
pygame.mixer.music.play(1)
sounds.msic2
I want to move your attention to the last two lines of code.
Pygame.mixer.music.play(1) obviously plays the music that I initialized and the very last line makes sure the second song is added to the queue (?). Note: "sounds." is from the imported sounds file
From what I understand having a 1 will ensure that the first song is played once followed by the queued song.
This does not happen. The first song is played but not the queued.
I do not get any errors and I have tried every search result on google to no avail.
I appreciate any help!
Thanks in advance,
Hoaz

New Topic/Question
Reply


MultiQuote




|