File: music.html

package info (click to toggle)
pygame 1.9.1release%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 7,280 kB
  • ctags: 6,685
  • sloc: ansic: 41,205; python: 21,987; cpp: 537; objc: 196; php: 92; sh: 77; makefile: 41
file content (215 lines) | stat: -rw-r--r-- 12,539 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215

<html>
<title>music - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.mixer.music">
<big><b>pygame.mixer.music</big></b><br><ul>
  <i>pygame module for controlling streamed audio</i><br>
<ul><small><table>
  <tr><td><a href="music.html#pygame.mixer.music.load">pygame.mixer.music.load</a> - <font size=-1>Load a music file for playback</font></td><td>Load a music file for playback</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.play">pygame.mixer.music.play</a> - <font size=-1>Start the playback of the music stream</font></td><td>Start the playback of the music stream</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.rewind">pygame.mixer.music.rewind</a> - <font size=-1>restart music</font></td><td>restart music</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.stop">pygame.mixer.music.stop</a> - <font size=-1>stop the music playback</font></td><td>stop the music playback</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.pause">pygame.mixer.music.pause</a> - <font size=-1>temporarily stop music playback</font></td><td>temporarily stop music playback</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.unpause">pygame.mixer.music.unpause</a> - <font size=-1>resume paused music</font></td><td>resume paused music</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.fadeout">pygame.mixer.music.fadeout</a> - <font size=-1>stop music playback after fading out</font></td><td>stop music playback after fading out</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.set_volume">pygame.mixer.music.set_volume</a> - <font size=-1>set the music volume</font></td><td>set the music volume</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.get_volume">pygame.mixer.music.get_volume</a> - <font size=-1>get the music volume</font></td><td>get the music volume</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.get_busy">pygame.mixer.music.get_busy</a> - <font size=-1>check if the music stream is playing</font></td><td>check if the music stream is playing</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.get_pos">pygame.mixer.music.get_pos</a> - <font size=-1>get the music play time</font></td><td>get the music play time</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.queue">pygame.mixer.music.queue</a> - <font size=-1>queue a music file to follow the current</font></td><td>queue a music file to follow the current</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.set_endevent">pygame.mixer.music.set_endevent</a> - <font size=-1>have the music send an event when playback stops</font></td><td>have the music send an event when playback stops</td></tr>
  <tr><td><a href="music.html#pygame.mixer.music.get_endevent">pygame.mixer.music.get_endevent</a> - <font size=-1>get the event a channel sends when playback stops</font></td><td>get the event a channel sends when playback stops</td></tr>
</table></small></ul>
<p>The music module is closely tied to <tt>pygame.mixer</tt>. Use the music module to control the playback of music in the sound mixer. </p>
<p>The difference between the music playback and regular Sound playback is that the music is streamed, and never actually loaded all at once. The mixer system only supports a single music stream at once. </p>
<p>Be aware that <tt>MP3</tt> support is limited. On some systems an unsupported format can crash the program, <tt>e.g</tt>. Debian Linux. Consider using <tt>OGG</tt> instead. </p>
<!--COMMENTS:pygame.mixer.music--> &nbsp;<br> 


<a name="pygame.mixer.music.load">
<big><b>pygame.mixer.music.load</big></b><br><ul>
  <i>Load a music file for playback</i><br>
  <tt>pygame.mixer.music.load(filename): return None</tt><br>
  <tt>pygame.mixer.music.load(object): return None</tt><br>
<p>This will load a music filename/file object and prepare it for playback. If a music stream is already playing it will be stopped. This does not start the music playing. </p>
<!--COMMENTS:pygame.mixer.music.load--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.play">
<big><b>pygame.mixer.music.play</big></b><br><ul>
  <i>Start the playback of the music stream</i><br>
  <tt>pygame.mixer.music.play(loops=0, start=0.0): return None</tt><br>
<p>This will play the loaded music stream. If the music is already playing it will be restarted. </p>
<p>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. </p>
<p>The starting position argument controls where in the music the song starts playing. The starting position is dependent on the format of music playing. <tt>MP3</tt> and <tt>OGG</tt> use the position as time (in seconds). <tt>MOD</tt> music it is the pattern order number. Passing a startpos will raise a NotImplementedError if it cannot set the start position </p>
<!--COMMENTS:pygame.mixer.music.play--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.rewind">
<big><b>pygame.mixer.music.rewind</big></b><br><ul>
  <i>restart music</i><br>
  <tt>pygame.mixer.music.rewind(): return None</tt><br>
<p>Resets playback of the current music to the beginning. </p>
<!--COMMENTS:pygame.mixer.music.rewind--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.stop">
<big><b>pygame.mixer.music.stop</big></b><br><ul>
  <i>stop the music playback</i><br>
  <tt>pygame.mixer.music.stop(): return None</tt><br>
<p>Stops the music playback if it is currently playing. </p>
<!--COMMENTS:pygame.mixer.music.stop--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.pause">
<big><b>pygame.mixer.music.pause</big></b><br><ul>
  <i>temporarily stop music playback</i><br>
  <tt>pygame.mixer.music.pause(): return None</tt><br>
<p>Temporarily stop playback of the music stream. It can be resumed with the <tt><a href="music.html#pygame.mixer.music.unpause">pygame.mixer.music.unpause</a> - <font size=-1>resume paused music</font></tt> function. </p>
<!--COMMENTS:pygame.mixer.music.pause--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.unpause">
<big><b>pygame.mixer.music.unpause</big></b><br><ul>
  <i>resume paused music</i><br>
  <tt>pygame.mixer.music.unpause(): return None</tt><br>
<p>This will resume the playback of a music stream after it has been paused. </p>
<!--COMMENTS:pygame.mixer.music.unpause--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.fadeout">
<big><b>pygame.mixer.music.fadeout</big></b><br><ul>
  <i>stop music playback after fading out</i><br>
  <tt>pygame.mixer.music.fadeout(time): return None</tt><br>
<p>This will stop the music playback after it has been faded out over the specified time (measured in milliseconds). </p>
<p>Note, that this function blocks until the music has faded out. </p>
<!--COMMENTS:pygame.mixer.music.fadeout--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.set_volume">
<big><b>pygame.mixer.music.set_volume</big></b><br><ul>
  <i>set the music volume</i><br>
  <tt>pygame.mixer.music.set_volume(value): return None</tt><br>
<p>Set the volume of the music playback. The value argument is between <tt>0.0</tt> and <tt>1.0</tt>. When new music is loaded the volume is reset. </p>
<!--COMMENTS:pygame.mixer.music.set_volume--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.get_volume">
<big><b>pygame.mixer.music.get_volume</big></b><br><ul>
  <i>get the music volume</i><br>
  <tt>pygame.mixer.music.get_volume(): return value</tt><br>
<p>Returns the current volume for the mixer. The value will be between <tt>0.0</tt> and <tt>1.0</tt>. </p>
<!--COMMENTS:pygame.mixer.music.get_volume--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.get_busy">
<big><b>pygame.mixer.music.get_busy</big></b><br><ul>
  <i>check if the music stream is playing</i><br>
  <tt>pygame.mixer.music.get_busy(): return bool</tt><br>
<p>Returns True when the music stream is actively playing. When the music is idle this returns False. </p>
<!--COMMENTS:pygame.mixer.music.get_busy--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.get_pos">
<big><b>pygame.mixer.music.get_pos</big></b><br><ul>
  <i>get the music play time</i><br>
  <tt>pygame.mixer.music.get_pos(): return time</tt><br>
<p>This gets the number of milliseconds that the music has been playing for. The returned time only represents how long the music has been playing; it does not take into account any starting position offsets. </p>
<!--COMMENTS:pygame.mixer.music.get_pos--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.queue">
<big><b>pygame.mixer.music.queue</big></b><br><ul>
  <i>queue a music file to follow the current</i><br>
  <tt>pygame.mixer.music.queue(filename): return None</tt><br>
<p>This will load a music file and queue it. <tt>A</tt> queued music file will begin as soon as the current music naturally ends. If the current music is ever stopped or changed, the queued song will be lost. </p>
<p>The following example will play music by Bach six times, then play music by Mozart once: </p>
<pre>    pygame.mixer.music.load('bach.ogg')
    pygame.mixer.music.play(5)        # Plays six times, not five!
    pygame.mixer.music.queue('mozart.ogg')
</pre>
<!--COMMENTS:pygame.mixer.music.queue--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.set_endevent">
<big><b>pygame.mixer.music.set_endevent</big></b><br><ul>
  <i>have the music send an event when playback stops</i><br>
  <tt>pygame.mixer.music.set_endevent(): return None</tt><br>
  <tt>pygame.mixer.music.set_endevent(type): return None</tt><br>
<p>This causes Pygame to signal (by means of the event queue) when the music is done playing. The argument determines the type of event that will be queued. </p>
<p>The event will be queued every time the music finishes, not just the first time. To stop the event from being queued, call this method with no argument. </p>
<!--COMMENTS:pygame.mixer.music.set_endevent--> &nbsp;<br> 
<br></ul>


<a name="pygame.mixer.music.get_endevent">
<big><b>pygame.mixer.music.get_endevent</big></b><br><ul>
  <i>get the event a channel sends when playback stops</i><br>
  <tt>pygame.mixer.music.get_endevent(): return type</tt><br>
<p>Returns the event type to be sent every time the music finishes playback. If there is no endevent the function returns <tt>pygame.NOEVENT</tt>. </p>
<!--COMMENTS:pygame.mixer.music.get_endevent--> &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>