kivy/kivy — pull request #1093 by akshayaurora (2013-04-10 19:17:59+00:00)
Title: core: audio_pygame support for seek and get_length from android mediaplayer

This is a part of https://github.com/kivy/python-for-android/pull/106

Testing with the following code::

```
from kivy.app import App
from kivy.core.audio import SoundLoader
from kivy.clock import Clock
from kivy.logger import Logger
from kivy.lang import Builder

root = Builder.load_string('''
BoxLayout:
audio_pos: 0
orientation: 'vertical'
Label:
text: str(slider.value)
Slider:
id: slider
min: 0.0
value: root.audio_pos
BoxLayout
Button:
text: "play"
on_press:
root.sound.play()
root.upd_pos()
Button:
text: 'stop'
on_release:
root.sound.stop()
slider.value = 0.0
root.upd_pos(stop=True)
Button:
text: 'seek to 20.0'
on_release: root.sound.seek(20.0)
''')

class TestApp(App):
def build(self):
root.sound = SoundLoader.load('audio02.ogg')
root.upd_pos = self.upd_pos
return root

def upd_pos(self, stop=False):
if stop:
Clock.unschedule(self.get_pos)
else:
Clock.unschedule(self.get_pos)
Clock.schedule_interval(self.get_pos, 1./9.)

def get_pos(self, dt):
root.ids.slider.max = root.sound._get_length()
root.audio_pos = root.sound.get_pos()

if __name__ == '__main__':
TestApp().run()
```
[1]: https://github.com/kivy/kivy/pull/new/android_mediaplayer_seek_length