File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ cdef class Voice(object):
53
53
def __cinit__ (
54
54
self ,
55
55
Sound sound ,
56
- object on_finish ,
56
+ object on_finish = None ,
57
57
int loop = False ,
58
58
Mixer mixer = None ,
59
59
):
@@ -62,7 +62,6 @@ cdef class Voice(object):
62
62
self .sound = sound
63
63
self .mixer = mixer
64
64
self .loop = loop
65
- self .handle = NULL
66
65
67
66
if on_finish:
68
67
context = CallbackContext(on_finish, self .sound)
@@ -80,7 +79,7 @@ cdef class Voice(object):
80
79
)
81
80
82
81
else :
83
- handle = gau.create_handle_sound(
82
+ self . handle = gau.create_handle_sound(
84
83
global_mixer,
85
84
self .sound.sound,
86
85
< ga.FinishCallback> & gau.on_finish_destroy,
@@ -91,12 +90,25 @@ cdef class Voice(object):
91
90
def play (self ):
92
91
ga.handle_play(self .handle)
93
92
93
+ @property
94
+ def playing (self ):
95
+ return bool (ga.handle_playing(self .handle))
96
+
94
97
def stop (self ):
95
98
ga.handle_stop(self .handle)
96
99
100
+ @property
101
+ def stopped (self ):
102
+ return bool (ga.handle_stopped(self .handle))
103
+
97
104
def __del__ (self ):
98
105
ga.handle_destroy(self .handle)
99
106
107
+ def toggle (self ):
108
+ if self .playing:
109
+ self .stop()
110
+ else :
111
+ self .play()
100
112
101
113
cdef class Sound(object ):
102
114
cdef ga.Sound* sound
@@ -108,7 +120,7 @@ cdef class Sound(object):
108
120
if not stream:
109
121
self .sound = gau.load_sound_file(filename, ext)
110
122
else :
111
- raise NotImplementedError (" streams ntt implemented yet" )
123
+ raise NotImplementedError (" streams not implemented yet" )
112
124
113
125
def play (self , on_finish = None ):
114
126
cdef Voice voice
You can’t perform that action at this time.
0 commit comments