Sub timer1_Tick
If mp.IsPlaying Then
SuraPos.Value = mp.Position / mp.Duration * 100
lblPosition.Text = ConvertToTimeFormat(mp.Position) & " / " & ConvertToTimeFormat(mp.Duration)
End If
End Sub
Sub ConvertToTimeFormat(ms As Int) As String
Dim seconds, minutes As Int
seconds = Round(ms / 1000)
minutes = Floor(seconds / 60)
seconds = seconds Mod 60
Return NumberFormat(minutes, 1, 0) & ":" & NumberFormat(seconds, 2, 0) 'ex: 3:05
End Sub
Sub SuraPos_ValueChanged (Value As Int, UserChanged As Boolean)
'Dim jo As JavaObject = mp
'jo.RunMethod("setPosition", Array As Object(3000))
If UserChanged = False Then Return 'the value was changed programmatically
mp.Position = Value / 100 * mp.Duration
If mp.IsPlaying = False Then 'this can happen when the playback reached the end and the user changes the position
mp.Play
End If
Log(mp.Position)
timer1_Tick 'immediately update the progress label
End Sub