Как привязать активную аудио к прогресс бару
from kivy._event import EventDispatcher
from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.progressbar import ProgressBar
class MyApp(App, EventDispatcher):
sound = SoundLoader.load('dummy.mp3')
def build(self):
mainbl = BoxLayout(orientation='vertical')
bl = BoxLayout(orientation='horizontal')
mainbl.add_widget(bl)
bl.add_widget(Button(text='1-ая песня',
on_press=self.btn_first))
bl.add_widget(Button(text='2-ая песня',
on_press=self.btn_second))
pb = ProgressBar(max=10,
size_hint=(None, None),
size=('600', '60'))
mainbl.add_widget(pb)
return mainbl
def btn_first(self, instance):
if self.sound.state == "play":
self.sound.stop()
self.sound = SoundLoader.load('01. Feed The Machine.mp3')
self.sound.play()
def btn_second(self, instance):
if self.sound.state == "play":
self.sound.stop()
self.sound = SoundLoader.load('02. Coin For The Ferryman.mp3')
self.sound.play()