From 545d7336d6212a55131a70b9ed7930ab4d358ba9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 30 Apr 2020 17:27:38 +0800 Subject: [PATCH] bugfix --- kivyblocks/aplayer.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kivyblocks/aplayer.py b/kivyblocks/aplayer.py index 8ecc73f..f9d65c9 100644 --- a/kivyblocks/aplayer.py +++ b/kivyblocks/aplayer.py @@ -26,11 +26,11 @@ class APlayer(BoxLayout): self.ap = None def on_source(self,o,s): + if self.ap: + self.ap.stop() self.ap = SoundFFPy(source=self.source) if not self.ap: return - self.ap.bind(on_play=self.begin_play) - self.ap.bind(on_stop=self.end_play) self.play() def __del__(self): @@ -45,11 +45,9 @@ class APlayer(BoxLayout): def play(self): if not self.ap: return + self.ap.bind(on_stop=self.end_play) self.ap.play() - def begin_play(self,obj): - pass - def end_play(self,obj): self.ap = None