<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-family: Verdana,Geneva,sans-serif'>
<p>Hola, muchas gracias por tu respuesta, ha sido la que necesitaba. Poniendo loops = -1 el tono se repite y aparte puedo seguir interactuando con los demás botones.</p>
<p>Muchas gracias también Grabriel Fernandez por tu respuesta.</p>
<p>Saludos</p>
<p> </p>
<p>El 2014-12-03 12:57, Python escribió:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<div class="moz-cite-prefix">Buenas,<br /> Creo que el comando play tiene un parámetro para indicarle que repita el fichero continuamente. loops = -1<br /> Por lo que no hace falta ningún while.<br /><br /><tt class="descclassname" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: bold; font-style: inherit; font-size: 1.1em; font-family: inherit; vertical-align: baseline;">pygame.mixer.music.</tt><tt class="descname" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: bold; font-style: inherit; font-size: 1.1em; font-family: inherit; vertical-align: baseline;">play</tt><big style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">(</big><big style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">)</big><br />
<div class="line-block" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">
<div class="line" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;"><span class="summaryline" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: italic; font-size: 16px; font-family: inherit; vertical-align: baseline;">Start the playback of the music stream</span></div>
<div class="line" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;"><span class="signature" style="margin: 0px  0px  0.5em; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 13px; font-family: monospace; vertical-align: baseline;">play(loops=0, start=0.0) -> None</span></div>
</div>
<p style="margin: 0.5em  0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline; text-align: left; line-height: 20.7999992370605px;">This will play the loaded music stream. If the music is already playing it will be restarted.</p>
<p style="margin: 0.5em  0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline; text-align: left; line-height: 20.7999992370605px;">The loops argument controls the number of repeats a music will play.<span class="Apple-converted-space"> </span><tt class="docutils literal" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;"><span class="pre" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">play(5)</span></tt><span class="Apple-converted-space"> </span>will cause the music to played once, then repeated five times, for a total of six. <strong>If the loops is -1 then the music will repeat indefinitely.</strong></p>
<p style="margin: 0.5em  0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline; text-align: left; line-height: 20.7999992370605px;">The starting position argument controls where in the music the song starts playing. The starting position is dependent on the format of music playing.<span class="Apple-converted-space"> </span><tt class="docutils literal" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;"><span class="pre" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">MP3</span></tt><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><tt class="docutils
            literal" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;"><span class="pre" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">OGG</span></tt><span class="Apple-converted-space"> </span>use the position as time (in seconds).<span class="Apple-converted-space"> </span><tt class="docutils literal" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;"><span class="pre" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-weight: inherit; font-style: inherit; font-size: 16px; font-family: inherit; vertical-align: baseline;">MOD</span></tt><span class="Apple-converted-space"> </span>music it is the pattern order number. Passing a startpos will raise a NotImplementedError if it cannot set the start position</p>
<br /> Saludos<br /><br /> El 03/12/2014 19:35, gabriel fernandez ha escrit:</div>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px">
<div dir="ltr">
<div>
<div>
<div>
<div>Hola Diego, usa una variable de instancia en tu clase para que sirva de bandera, por ejemplo:<br /><br /></div>
class Algo:<br /><br /></div>
    def __init__(self):</div>
        self.flag_presionar_btn = False<br /><br /></div>
    def btn_mi_clicked(self):<br />         self.flag_presionar_btn = True<br />         pygame.mixer.music.stop()<br />         <br />         while True:<br />             pygame.mixer.init()<br />            pygame.mixer.music.load("mi.
<div>mp3")<br />             pygame.mixer.music.play()<br />             time.sleep()<br />             pygame.mixer.music.stop()<br /><br />             if not self.flag_presionar_btn:</div>
<div>                break<br /><br /><br /></div>
<div>No se si queda claro, espero te sirva, saludos!</div>
</div>
<div class="gmail_extra"> </div>
</blockquote>
</blockquote>
</body></html>