kivy/python-for-android — pull request #106 by akshayaurora (2013-04-10 18:51:50+00:00)
Title: seek, get_pos  and get_length support for mediaplayer

Testing with the following code and `android_mediaplayer_seek_length` branch of kivy for the changes that were needed to audio_pygame. Currently wrong pos(off by a few secs) is displayed with vorbis files (known issue with Android MediaPlayer).

```
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()
```