~pygame/pygame/trunk

« back to all changes in this revision

Viewing changes to test/mixer_music_test.py

  • Committer: pygame
  • Date: 2017-01-10 00:31:42 UTC
  • Revision ID: git-v1:2eea4f299a2e791f884608d7ed601558634af73c
commit 1639c41a8cb3433046882ede92c80ce69d59016b
Author: Thomas Kluyver <takowl@gmail.com>
Date:   Sun Jan 8 18:46:46 2017 +0000

    Build newer versions of libogg and libvorbis into Linux base images

    Closes #317
    Closes #323

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sys
 
2
if __name__ == '__main__':
 
3
    import os
 
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')
 
8
    if not is_pygame_pkg:
 
9
        sys.path.insert(0, parent_dir)
 
10
else:
 
11
    is_pygame_pkg = __name__.startswith('pygame.tests.')
 
12
 
 
13
import unittest
 
14
if is_pygame_pkg:
 
15
    from pygame.tests.test_utils import example_path
 
16
else:
 
17
    from test.test_utils import example_path
 
18
import pygame
 
19
from pygame.compat import as_unicode, filesystem_encode
 
20
 
 
21
import os
 
22
 
 
23
class MixerMusicModuleTest(unittest.TestCase):
 
24
    def test_load(self):
 
25
        "|tags:music|"
 
26
        # __doc__ (as of 2008-07-13) for pygame.mixer_music.load:
 
27
 
 
28
          # pygame.mixer.music.load(filename): return None
 
29
          # Load a music file for playback
 
30
 
 
31
        data_fname = example_path('data')
 
32
        pygame.mixer.init()
 
33
 
 
34
        # The mp3 test file can crash smpeg on some systems.
 
35
        ## formats = ['mp3', 'ogg', 'wav']
 
36
        formats = ['ogg', 'wav']
 
37
 
 
38
        for f in formats:
 
39
            path = os.path.join(data_fname, 'house_lo.%s' % f)
 
40
            if os.sep == '\\':
 
41
                path = path.replace('\\', '\\\\')
 
42
            umusfn = as_unicode(path)
 
43
            bmusfn = filesystem_encode(umusfn)
 
44
 
 
45
            pygame.mixer.music.load(umusfn)
 
46
            pygame.mixer.music.load(bmusfn)
 
47
 
 
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))
 
51
            #musf = open(musfn)
 
52
            #pygame.mixer.music.load(musf)
 
53
        pygame.mixer.quit()
 
54
 
 
55
    def todo_test_queue(self):
 
56
 
 
57
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.queue:
 
58
 
 
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.
 
62
          #
 
63
          # The following example will play music by Bach six times, then play
 
64
          # music by Mozart once:
 
65
          #
 
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')
 
69
 
 
70
        self.fail()
 
71
 
 
72
    def todo_test_stop(self):
 
73
 
 
74
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.stop:
 
75
 
 
76
          # Stops the music playback if it is currently playing.
 
77
 
 
78
        self.fail()
 
79
 
 
80
    def todo_test_rewind(self):
 
81
 
 
82
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.rewind:
 
83
 
 
84
          # Resets playback of the current music to the beginning.
 
85
 
 
86
        self.fail()
 
87
 
 
88
    def todo_test_get_pos(self):
 
89
 
 
90
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.get_pos:
 
91
 
 
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
 
95
          # offsets.
 
96
          #
 
97
 
 
98
        self.fail()
 
99
 
 
100
    def todo_test_fadeout(self):
 
101
 
 
102
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.fadeout:
 
103
 
 
104
          # This will stop the music playback after it has been faded out over
 
105
          # the specified time (measured in milliseconds).
 
106
          #
 
107
          # Note, that this function blocks until the music has faded out.
 
108
 
 
109
        self.fail()
 
110
 
 
111
    def todo_test_play(self):
 
112
 
 
113
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.play:
 
114
 
 
115
          # This will play the loaded music stream. If the music is already
 
116
          # playing it will be restarted.
 
117
          #
 
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.
 
122
          #
 
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
 
128
          #
 
129
 
 
130
        self.fail()
 
131
 
 
132
    def todo_test_load(self):
 
133
 
 
134
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.load:
 
135
 
 
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
 
138
          # the music playing.
 
139
          #
 
140
          # Music can only be loaded from filenames, not python file objects
 
141
          # like the other pygame loading functions.
 
142
          #
 
143
 
 
144
        self.fail()
 
145
 
 
146
    def todo_test_get_volume(self):
 
147
 
 
148
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.get_volume:
 
149
 
 
150
          # Returns the current volume for the mixer. The value will be between
 
151
          # 0.0 and 1.0.
 
152
          #
 
153
 
 
154
        self.fail()
 
155
 
 
156
    def todo_test_set_endevent(self):
 
157
 
 
158
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.set_endevent:
 
159
 
 
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.
 
163
          #
 
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
 
166
          # with no argument.
 
167
          #
 
168
 
 
169
        self.fail()
 
170
 
 
171
    def todo_test_pause(self):
 
172
 
 
173
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.pause:
 
174
 
 
175
          # Temporarily stop playback of the music stream. It can be resumed
 
176
          # with the pygame.mixer.music.unpause() function.
 
177
          #
 
178
 
 
179
        self.fail()
 
180
 
 
181
    def todo_test_get_busy(self):
 
182
 
 
183
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.get_busy:
 
184
 
 
185
          # Returns True when the music stream is actively playing. When the
 
186
          # music is idle this returns False.
 
187
          #
 
188
 
 
189
        self.fail()
 
190
 
 
191
    def todo_test_get_endevent(self):
 
192
 
 
193
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.get_endevent:
 
194
 
 
195
          # Returns the event type to be sent every time the music finishes
 
196
          # playback. If there is no endevent the function returns
 
197
          # pygame.NOEVENT.
 
198
          #
 
199
 
 
200
        self.fail()
 
201
 
 
202
    def todo_test_unpause(self):
 
203
 
 
204
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.unpause:
 
205
 
 
206
          # This will resume the playback of a music stream after it has been paused.
 
207
 
 
208
        self.fail()
 
209
 
 
210
    def todo_test_set_volume(self):
 
211
 
 
212
        # __doc__ (as of 2008-08-02) for pygame.mixer_music.set_volume:
 
213
 
 
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.
 
216
          #
 
217
 
 
218
        self.fail()
 
219
 
 
220
    def todo_test_set_pos(self):
 
221
 
 
222
        # __doc__ (as of 2010-24-05) for pygame.mixer_music.set_pos:
 
223
 
 
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.
 
229
          #
 
230
 
 
231
        self.fail()
 
232
 
 
233
if __name__ == '__main__':
 
234
    unittest.main()