1. pygame
  2. Untitled project
  3. pygame


pygame / docs / ref / pygame_mixer_music.html

<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>
<td valign=middle><tt><font color=#dddddd><br>
</td></tr></table></td><td width=100% align=center valign=middle>

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

|| <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_UserRect.html>UserRect</a> || 
<a href=pygame_cdrom.html>cdrom</a> || 
<a href=pygame_constants.html>constants</a> || 
<a href=pygame_cursors.html>cursors</a> || 
<a href=pygame_display.html>display</a> || 
<a href=pygame_event.html>event</a> ||<br>
|| <a href=pygame_font.html>font</a> || 
<a href=pygame_image.html>image</a> || 
<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> ||<br>
|| <a href=pygame_surfarray.html>surfarray</a> || 
<a href=pygame_time.html>time</a> || 
<a href=pygame_version.html>version</a> ||<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.
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.
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.


<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>



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

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

<a name=get_endevent><font size=+2><b>get_endevent
</b></font><br><font size=+1><tt>
pygame.mixer.music.get_endevent([eventid]) -> int
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.

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

<a name=load><font size=+2><b>load
</b></font><br><font size=+1><tt>
pygame.mixer.music.load(filename) -> None
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.

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

<a name=play><font size=+2><b>play
</b></font><br><font size=+1><tt>
pygame.mixer.music.play([loops]) -> None
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.

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

<a name=set_endevent><font size=+2><b>set_endevent
</b></font><br><font size=+1><tt>
pygame.mixer.music.set_endevent([eventid]) -> None
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.

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

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

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