Kivy: Sound starts to play, but is 'unstoppable' on Android, but on Windows it works
I got a series of ToggleButtons in kivy, with each loaded a different soundfile.
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:
- Create an AudioButton instance with previously specified soundfile (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 changes
- When the Button is state=='down' the sound plays, and the Text of the Button gets a Caption appended
- If the Button is state=='normal' it stops the currently playing sound, if the concerning Button gets pressed, if another Button gets pressed, theres the Callback:
- directly stops the sound when state changes
- removes previously added Caption and resizes the Button
On Windows, everything works fine with this code. On Android however, when the killsound get's 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, the new one starts, so I got both sound playing at the same time, same with more than two sounds.
Can you help me?
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 :)