我在网上找到了这个要点,帮助我的kivy应用程序完美地在线传输音频,但是当我试图阻止它播放时,应用程序失败了。这是代码..
def play(self,name):
print 'playing'
from jnius import autoclass
from time import sleep
MediaPlayer = autoclass('android.media.MediaPlayer')
mPlayer = MediaPlayer()
mPlayer.setDataSource('{}'.format(self.source))
mPlayer.prepare()
duration = mPlayer.getDuration()
if self.ids.play_stop.text =='Play':
# mPlayer.prepare()
print 'play'
self.ids.play_stop.text = 'Stop'
mPlayer.start()
# print 'current position:', mPlayer.getCurrentPosition()
sleep(int(duration))
elif self.ids.play_stop.text =='Stop':
print 'stop'
self.ids.play_stop.text = 'Play'
# sleep(3)
mPlayer.pause()
任何解决方法吗?