I got a series of ToggleButtons in kivy, with each loaded with a different sound file. When I try my Code in Windows, everything works as expected, but on Android via the Kivy Launcher, the sound doesn't get stopped.
class AudioButton(ToggleButton):
sound = ObjectProperty(None)
def killsound(self, state, dt):
self.sound.stop()
if 'Click to stop' in self.text:
self.text = self.text.strip('\nClick to stop')
self.height = 60
else:
pass
def on_press(self):
self.bind(state=self.killsound)
if self.state == 'normal':
self.sound.stop()
else:
self.sound.play()
self.text = self.text+'\nClick to stop'
self.height=240
Here's what it does / should do:
AudioButton
instance with a previously specified sound file (also specified: size_hint
, font_size
, and group
(to act as radio buttons)on_press
fires the callback killsound
when the state of the Button changesstate=='down'
the sound plays, and the Text of the Button gets a Caption appendedstate=='normal'
it stops the currently playing sound, if the concerning Button gets pressed, if another Button gets pressed, there's the Callback:Callback(killsound):
On Windows, everything works fine with this code.
On Android, however, when the killsound
gets called, it removes the caption and resizes the Button, but it won't stop the sound - The old sound (which should be stopped) is still playing, and the new one starts, so I got both sounds playing at the same time, same with more than two sounds.
Any help is appreciated.
This have been fixed in Kivy 1.4.1. You should talk to us via mailing list, or report a github issue instead of posting here :)