Source

pygame / docs / ref / pygame_mixer_music.html

Full commit
<html>
<title>pygame.mixer.music</title>
<body bgcolor=#dddddd text=#333377 link=#7777bb vlink=#7777bb>

<table border=0 width=100% cellpadding=0 cellspacing=0 bgcolor=#f5f5f5><tr valign=top>
<td rowspan=2><table border=0 cellpadding=5 cellspacing=0 bgcolor=#333377>
<tr height=86 align=left><td valign=middle><font color=#ffffff size=+5>
	<a href=../index.html><font size=+5 color=#ffffff><i><b>
      pygame</b></i></font></a>&nbsp;&nbsp;</td>
<td valign=middle><tt><font color=#dddddd><br>
	pygame<br>documentation</font>
</td></tr></table></td><td width=100% align=center valign=middle>

	||&nbsp;
	<a href=http://pygame.seul.org>Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<br>&nbsp;<br>

|| <a href=CD.html>CD</a> || 
<a href=Channel.html>Channel</a> || 
<a href=Font.html>Font</a> || 
<a href=Joystick.html>Joystick</a> || 
<a href=Rect.html>Rect</a> || 
<a href=Sound.html>Sound</a> || 
<a href=Surface.html>Surface</a> ||<br>
|| <a href=pygame.html>pygame</a> || 
<a href=pygame_cdrom.html>cdrom</a> || 
<a href=pygame_constants.html>constants</a> || 
<a href=pygame_display.html>display</a> || 
<a href=pygame_event.html>event</a> || 
<a href=pygame_font.html>font</a> || 
<a href=pygame_image.html>image</a> ||<br>
|| <a href=pygame_joystick.html>joystick</a> || 
<a href=pygame_key.html>key</a> || 
<a href=pygame_mixer.html>mixer</a> || 
<a href=pygame_mixer_music.html>mixer_music</a> || 
<a href=pygame_mouse.html>mouse</a> || 
<a href=pygame_surfarray.html>surfarray</a> || 
<a href=pygame_time.html>time</a> ||<br>


</td></tr></table>
<br>
<h2 align=center>pygame.mixer.music</h2>
The music module is tied closely to the pygame.mixer module. It
is an optional module since it depends on the SDL_mixer library.
You should not manually import the music library. Instead it is
automatically included as a part of the mixer library. The default
module path to music is pygame.mixer.music.
<br>&nbsp;<br>
The difference between playback of music and playback of sounds
is that the music object is not loaded and decoded all at once,
instead the music data is streamed and decoded during playback.
There can only be one music file loaded at a single time. Loading
a new music file will replace any currently loaded music.
<br>&nbsp;<br>
The music module has many of the same types of functions as the
Sound objects. The main difference is only one music object can
be loaded at a time, with the pygame.music.load() function. Music
must be stored in an individual file on the system, it cannot be
loaded from special file-like objects through python.

<hr>

<table>
<tr><td><a href=#fadeout>fadeout</a></td><td> -
fadeout current music</td></tr>


<tr><td><a href=#get_busy>get_busy</a></td><td> -
query state of the music</td></tr>


<tr><td><a href=#get_endevent>get_endevent</a></td><td> -
query the current music finished event</td></tr>


<tr><td><a href=#get_volume>get_volume</a></td><td> -
query music volume</td></tr>


<tr><td><a href=#load>load</a></td><td> -
load current music</td></tr>


<tr><td><a href=#pause>pause</a></td><td> -
pause the playing music</td></tr>


<tr><td><a href=#play>play</a></td><td> -
play the current loaded music</td></tr>


<tr><td><a href=#rewind>rewind</a></td><td> -
restarts music</td></tr>


<tr><td><a href=#set_endevent>set_endevent</a></td><td> -
sets music finished event</td></tr>


<tr><td><a href=#set_volume>set_volume</a></td><td> -
set music volume</td></tr>


<tr><td><a href=#stop>stop</a></td><td> -
stop the playing music</td></tr>


<tr><td><a href=#unpause>unpause</a></td><td> -
restarts the paused music</td></tr>


</table>

<hr>

<a name=fadeout><font size=+2><b>fadeout
</b></font><br><font size=+1><tt>
pygame.mixer.music.fadeout(millisec) -> None
</tt></font><ul>
Fades out the current playing music and stops it over the given
milliseconds.
</ul><br>&nbsp;<br>

<a name=get_busy><font size=+2><b>get_busy
</b></font><br><font size=+1><tt>
pygame.mixer.music.get_busy() -> bool
</tt></font><ul>
Returns true if music is currently playing
</ul><br>&nbsp;<br>

<a name=get_endevent><font size=+2><b>get_endevent
</b></font><br><font size=+1><tt>
pygame.mixer.music.get_endevent([eventid]) -> int
</tt></font><ul>
When the music has finished playing, you can optionally have
pygame place a user defined message on the event queue. If there
is no callback event set, NOEVENT will be returned. Otherwise it
will return the id of the current music finishe event.
</ul><br>&nbsp;<br>

<a name=get_volume><font size=+2><b>get_volume
</b></font><br><font size=+1><tt>
pygame.mixer.music.get_volume() -> val
</tt></font><ul>
Get the current volume for the music. Value is
between 0.0 and 1.0.
</ul><br>&nbsp;<br>

<a name=load><font size=+2><b>load
</b></font><br><font size=+1><tt>
pygame.mixer.music.load(filename) -> None
</tt></font><ul>
Load a music object as the current music. The music only handles
one music as the current. If music is currently playing, it will
be stopped and replaced with the given one. Loading music only
supports filenames, not file-like objects.
</ul><br>&nbsp;<br>

<a name=pause><font size=+2><b>pause
</b></font><br><font size=+1><tt>
pygame.mixer.music.pause() -> None
</tt></font><ul>
Temporarily stops the current music.
</ul><br>&nbsp;<br>

<a name=play><font size=+2><b>play
</b></font><br><font size=+1><tt>
pygame.mixer.music.play([loops]) -> None
</tt></font><ul>
Starts playing the current loaded music. This will restart the
sound if it is playing. Loops controls how many extra time the
sound will play, a negative loop will play indefinitely, it
defaults to 0.
</ul><br>&nbsp;<br>

<a name=rewind><font size=+2><b>rewind
</b></font><br><font size=+1><tt>
pygame.mixer.music.rewind() -> None
</tt></font><ul>
Restarts playback of the current music.
</ul><br>&nbsp;<br>

<a name=set_endevent><font size=+2><b>set_endevent
</b></font><br><font size=+1><tt>
pygame.mixer.music.set_endevent([eventid]) -> None
</tt></font><ul>
When the music has finished playing, you can optionally have
pygame place a user defined message on the event queue. If the
eventid field is omittied or NOEVENT, no messages will be sent
when the music finishes playing. Once the endevent is set, it
will be called every time the music finished playing.
</ul><br>&nbsp;<br>

<a name=set_volume><font size=+2><b>set_volume
</b></font><br><font size=+1><tt>
pygame.mixer.music.set_volume(val) -> None
</tt></font><ul>
Sets the current volume for the music. Value is
between 0.0 and 1.0.
</ul><br>&nbsp;<br>

<a name=stop><font size=+2><b>stop
</b></font><br><font size=+1><tt>
pygame.mixer.music.stop() -> None
</tt></font><ul>
Stops playback of the current music.
</ul><br>&nbsp;<br>

<a name=unpause><font size=+2><b>unpause
</b></font><br><font size=+1><tt>
pygame.mixer.music.unpause() -> None
</tt></font><ul>
Restarts playback of the current music object when paused.
</ul><br>&nbsp;<br>


<hr>

</body></html>