Buenas,
Creo que el comando play tiene un parámetro para indicarle que repita el
fichero continuamente. loops = -1
Por lo que no hace falta ningún while.
pygame.mixer.music.play()
Start the playback of the music stream
play(loops=0, start=0.0) -> None
This will play the loaded music stream. If the music is already
playing it will be restarted.
The loops argument controls the number of repeats a music will
play.play(5)will cause the music to played once, then repeated five
times, for a total of six. *If the loops is -1 then the music will
repeat indefinitely.*
The starting position argument controls where in the music the song
starts playing. The starting position is dependent on the format of
music playing.MP3andOGGuse the position as time (in
seconds).MODmusic it is the pattern order number. Passing a startpos
will raise a NotImplementedError if it cannot set the start position
Saludos
El 03/12/2014 19:35, gabriel fernandez ha escrit:
Hola Diego, usa una variable de instancia en tu clase para que sirva
de bandera, por ejemplo:
class Algo:
def __init__(self):
self.flag_presionar_btn = False
def btn_mi_clicked(self):
self.flag_presionar_btn = True
pygame.mixer.music.stop()
while True:
pygame.mixer.init()
pygame.mixer.music.load("mi.
mp3")
pygame.mixer.music.play()
time.sleep()
pygame.mixer.music.stop()
if not self.flag_presionar_btn:
break
No se si queda claro, espero te sirva, saludos!
El 3 de diciembre de 2014, 14:24, Diego Caraballo
<dcaraba...@amsj.com.uy <mailto:dcaraba...@amsj.com.uy>> escribió:
Gracias por tu respuesta Flavio, con info de tu página fue que
opte utilizar pygame para el sonido de la aplicación :).
Esto creo que ya lo había probado, funciona si, pero la idea era
que la nota se repitiera hasta que otro botón fuera presionado
(por eso quise implementar el while, y por eso la función arranca
con pygame.mixer.music.stop() para detenr el sonido y arrancar uno
nuevo). Quizá tenga que echar un poco de mano a los eventos de
pygame?
Saludos
El 2014-12-03 09:12, Flavio Danesse escribió:
Tienes que eliminar el while.
Solo carga el archivo y hazle play.
Toma en cuenta que con pygame puedes reproducir hasta ocho
sonidos a la vez.
El 3 de diciembre de 2014, 2:43, Diego Caraballo
<dcaraba...@amsj.com.uy <mailto:dcaraba...@amsj.com.uy>> escribió:
Buenas noches gente, estoy tratando de hacer una GUI
(*pyqt4*) con algunos botones que reproduzcan sonidos (notas
musicales). La idea es que cada ves que se presione un botón,
se reproduzca la nota y se repita hasta que otra nota sea
presionada. Estoy utilizando *pygame* para reproducir el sonido.
El problema surge cuando presiono la nota, al entrar en el
while el programa no deja hacer más nada, sigue reproduciendo
la nota y se cuelga.
Creo que estoy teniendo el mismo problema que este señor:
https://mail.python.org/pipermail/tkinter-discuss/2013-June/003451.html
Alguno sabría como matar el evento? o hacer que el evento se
ejecute en segundo plano y me deje seguir presionando otros
botones?
Les dejo una de las funciones a llamar:
def btn_mi_clicked(self):
pygame.mixer.music.stop()
while True:
pygame.mixer.init()
pygame.mixer.music.load("mi.mp3")
pygame.mixer.music.play()
time.sleep()
pygame.mixer.music.stop()
Desde ya muchas gracias
Diego Caraballo
*www.pythondiario.com* <http://www.pythondiario.com>
_______________________________________________
Python-es mailing list
Python-es@python.org <mailto:Python-es@python.org>
https://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/
_______________________________________________
Python-es mailing list
Python-es@python.org <mailto:Python-es@python.org>
https://mail.python.org/mailman/listinfo/python-es
FAQ:http://python-es-faq.wikidot.com/
--
Departamento de TI - AMSJ Coop.
Diego Caraballo
Cel: 091425426 <tel:091425426>
logo
_______________________________________________
Python-es mailing list
Python-es@python.org <mailto:Python-es@python.org>
https://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/
--
Gabriel Fernández
Desrrollador Web
www.openweb.com.uy <http://www.openweb.com.uy>
_______________________________________________
Python-es mailing list
Python-es@python.org
https://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/
_______________________________________________
Python-es mailing list
Python-es@python.org
https://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/