2
if __name__ == '__main__':
4
pkg_dir = os.path.split(os.path.abspath(__file__))[0]
5
parent_dir, pkg_name = os.path.split(pkg_dir)
6
is_pygame_pkg = (pkg_name == 'tests' and
7
os.path.split(parent_dir)[1] == 'pygame')
9
sys.path.insert(0, parent_dir)
11
is_pygame_pkg = __name__.startswith('pygame.tests.')
15
from pygame.tests.test_utils import example_path
17
from test.test_utils import example_path
19
from pygame.compat import as_unicode, filesystem_encode
23
class MixerMusicModuleTest(unittest.TestCase):
26
# __doc__ (as of 2008-07-13) for pygame.mixer_music.load:
28
# pygame.mixer.music.load(filename): return None
29
# Load a music file for playback
31
data_fname = example_path('data')
34
# The mp3 test file can crash smpeg on some systems.
35
## formats = ['mp3', 'ogg', 'wav']
36
formats = ['ogg', 'wav']
39
path = os.path.join(data_fname, 'house_lo.%s' % f)
41
path = path.replace('\\', '\\\\')
42
umusfn = as_unicode(path)
43
bmusfn = filesystem_encode(umusfn)
45
pygame.mixer.music.load(umusfn)
46
pygame.mixer.music.load(bmusfn)
48
#NOTE: TODO: loading from filelikes are disabled...
49
# because as of writing it only works in SDL_mixer svn.
50
#pygame.mixer.music.load(open(musfn))
52
#pygame.mixer.music.load(musf)
55
def todo_test_queue(self):
57
# __doc__ (as of 2008-08-02) for pygame.mixer_music.queue:
59
# This will load a music file and queue it. A queued music file will
60
# begin as soon as the current music naturally ends. If the current
61
# music is ever stopped or changed, the queued song will be lost.
63
# The following example will play music by Bach six times, then play
64
# music by Mozart once:
66
# pygame.mixer.music.load('bach.ogg')
67
# pygame.mixer.music.play(5) # Plays six times, not five!
68
# pygame.mixer.music.queue('mozart.ogg')
72
def todo_test_stop(self):
74
# __doc__ (as of 2008-08-02) for pygame.mixer_music.stop:
76
# Stops the music playback if it is currently playing.
80
def todo_test_rewind(self):
82
# __doc__ (as of 2008-08-02) for pygame.mixer_music.rewind:
84
# Resets playback of the current music to the beginning.
88
def todo_test_get_pos(self):
90
# __doc__ (as of 2008-08-02) for pygame.mixer_music.get_pos:
92
# This gets the number of milliseconds that the music has been playing
93
# for. The returned time only represents how long the music has been
94
# playing; it does not take into account any starting position
100
def todo_test_fadeout(self):
102
# __doc__ (as of 2008-08-02) for pygame.mixer_music.fadeout:
104
# This will stop the music playback after it has been faded out over
105
# the specified time (measured in milliseconds).
107
# Note, that this function blocks until the music has faded out.
111
def todo_test_play(self):
113
# __doc__ (as of 2008-08-02) for pygame.mixer_music.play:
115
# This will play the loaded music stream. If the music is already
116
# playing it will be restarted.
118
# The loops argument controls the number of repeats a music will play.
119
# play(5) will cause the music to played once, then repeated five
120
# times, for a total of six. If the loops is -1 then the music will
121
# repeat indefinitely.
123
# The starting position argument controls where in the music the song
124
# starts playing. The starting position is dependent on the format of
125
# music playing. MP3 and OGG use the position as time (in seconds).
126
# MOD music it is the pattern order number. Passing a startpos will
127
# raise a NotImplementedError if it cannot set the start position
132
def todo_test_load(self):
134
# __doc__ (as of 2008-08-02) for pygame.mixer_music.load:
136
# This will load a music file and prepare it for playback. If a music
137
# stream is already playing it will be stopped. This does not start
140
# Music can only be loaded from filenames, not python file objects
141
# like the other pygame loading functions.
146
def todo_test_get_volume(self):
148
# __doc__ (as of 2008-08-02) for pygame.mixer_music.get_volume:
150
# Returns the current volume for the mixer. The value will be between
156
def todo_test_set_endevent(self):
158
# __doc__ (as of 2008-08-02) for pygame.mixer_music.set_endevent:
160
# This causes Pygame to signal (by means of the event queue) when the
161
# music is done playing. The argument determines the type of event
162
# that will be queued.
164
# The event will be queued every time the music finishes, not just the
165
# first time. To stop the event from being queued, call this method
171
def todo_test_pause(self):
173
# __doc__ (as of 2008-08-02) for pygame.mixer_music.pause:
175
# Temporarily stop playback of the music stream. It can be resumed
176
# with the pygame.mixer.music.unpause() function.
181
def todo_test_get_busy(self):
183
# __doc__ (as of 2008-08-02) for pygame.mixer_music.get_busy:
185
# Returns True when the music stream is actively playing. When the
186
# music is idle this returns False.
191
def todo_test_get_endevent(self):
193
# __doc__ (as of 2008-08-02) for pygame.mixer_music.get_endevent:
195
# Returns the event type to be sent every time the music finishes
196
# playback. If there is no endevent the function returns
202
def todo_test_unpause(self):
204
# __doc__ (as of 2008-08-02) for pygame.mixer_music.unpause:
206
# This will resume the playback of a music stream after it has been paused.
210
def todo_test_set_volume(self):
212
# __doc__ (as of 2008-08-02) for pygame.mixer_music.set_volume:
214
# Set the volume of the music playback. The value argument is between
215
# 0.0 and 1.0. When new music is loaded the volume is reset.
220
def todo_test_set_pos(self):
222
# __doc__ (as of 2010-24-05) for pygame.mixer_music.set_pos:
224
#This sets the position in the music file where playback will start. The
225
# meaning of "pos", a float (or a number that can be converted to a float),
226
# depends on the music format. Newer versions of SDL_mixer have better
227
# positioning support than earlier. An SDLError is raised if a particular
228
# format does not support positioning.
233
if __name__ == '__main__':