Android Question media player - positioning seekbar

merlin2049er

Well-Known Member
Licensed User
Longtime User
Ok, what I'm trying to do is use bookmarks (or chapters) in a listview to jump to a position in an audio file (.mp3). I converted the mm:ss to seconds. I have the number of seconds where each chapter begins, in an array (along with the title of the chapter). The duration of the mp3 is like 30 minutes (or 1800 seconds).

I've got some of Erel's code right here...

B4X:
Sub barPosition_ValueChanged (Value As Int, UserChanged As Boolean)
    If UserChanged = False Then Return 'the value was changed programmatically
    MediaPlayer1.Position = Value / 100 * MediaPlayer1.Duration
    If MediaPlayer1.IsPlaying = False Then 'this can happen when the playback reached the end and the user changes the position
        MediaPlayer1.Play
    End If
    timer1_Tick 'immediately update the progress label
End Sub

I would imagine I should pass some value into this code to move my position. The other thing is, how accurate would positioning audio if the progress bar is only 100 units? Should it not be the duration of the file itself?

Any suggestions?
Thanks,
Joe
 

sorex

Expert
Licensed User
Longtime User
just get the id of the pressed listview item, look up the seconds/position and modify the play position with .position.
 
Upvote 0
Top