devenh
Posts: 25
Joined: Fri Jun 05, 2015 9:11 pm

pygame.mixer.music.queue not working for me!

Mon Mar 28, 2016 2:49 pm

I'm sure I'm missing something simple, but I just can't get the queue function to work. I'm using Python 3.4.2 under the latest Jessie release on a Pi 3. I have tested with wav and ogg files.

Code: Select all

PATHAUDIO = '/home/pi/Music/'
ext = '.ogg'
print(ext)
pygame.mixer.init()
pygame.mixer.music.load(PATHAUDIO + 'first' + ext)
pygame.mixer.music.play(2)
pygame.mixer.music.queue(PATHAUDIO + 'second' + ext)
#pygame.mixer.music.play()
print('done')
The first audio file gets played three times, but the second one is never played.

User avatar
elParaguayo
Posts: 1849
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: pygame.mixer.music.queue not working for me!

Wed Mar 30, 2016 7:00 pm

Can you verify that the second file plays through pygame?

Also, how are you running this code? If you execute it as a python script then, without some loop at the end, the code will just exit.

I don't have a pi that I can easily test this on. However, I've tested it on my laptop (Ubuntu) and it works as expected for me.

This was the code I ran:

Code: Select all

import pygame
import time

mix = pygame.mixer  # This is just me being lazy!
music = mix.music  # ditto

f1 = "/usr/share/sounds/alsa/Front_Center.wav"
f2 = "/usr/share/sounds/alsa/Front_Left.wav"

mix.init()
music.load(f1)
music.play(2)
music.queue(f2)
print "Done"

time.sleep(15)
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

devenh
Posts: 25
Joined: Fri Jun 05, 2015 9:11 pm

Re: pygame.mixer.music.queue not working for me!

Sat Apr 02, 2016 1:14 pm

elParaguayo wrote:Can you verify that the second file plays through pygame?
Yes it does.
Also, how are you running this code? If you execute it as a python script then, without some loop at the end, the code will just exit.
I thought the same thing and had already tried adding sleep(20), but same result.

It appears the problem is pi specific as the code works on your laptop.

devenh
Posts: 25
Joined: Fri Jun 05, 2015 9:11 pm

Re: pygame.mixer.music.queue not working for me!

Sun May 22, 2016 5:13 pm

If pygame.mixer.music.queue does not work, can anyone suggest an alternative python library that has the ability to queue music in a non blocking fashion?

Return to “Python”

Who is online

Users browsing this forum: asavah and 19 guests