Reputation: 1
I want to play an audio file and when the user presses the second item of the dropdown menu it stops the previous file and starts the next. I used the following code but the files play all at the same time. Another question, is soundloader cross-platform? Please explain in detail.
class Mywidget(Screen):
sound = SoundLoader.load("listening/17.mp3")
def check(self,*args):
if 'news' in self.ids:
sound = SoundLoader.load("listening/17.mp3")
sound.play()
f = open(r'listening/newspaper.txt',"r").read()
self.ids.mytext.multiline = True
self.ids.mytext.text = f
if 'practical' in self.ids:
sound.stop()
sound.unload()
sound = SoundLoader.load("listening/2.mp3")
sound.play()
a = open(r'listening/a practical skill.txt',"r").read()
self.ids.mytext.multiline = True
self.ids.mytext.text = a
if 'presents' in self.ids:
sound.stop()
sound = SoundLoader.load("listening/PRESENTS.mp3")
sound.play()
sound.loop = True
b = open(r'listening/presents.txt',"r").read()
self.ids.mytext.multiline = True
self.ids.mytext.text = b
ActionButton:
id:news
text: 'News paper and Magazine'
on_press:root.check()
ActionButton:
id:practical
text: 'A practical skill'
on_press:root.check()
ActionButton:
id:presents
text: 'Presents'
on_press:root.check()
Upvotes: 0
Views: 29