Android Question Convert MediaPlayerTimeFormat to MediaPlayer Format

ArminKH

Well-Known Member
hi as you can see in media player tutorial we have a sub named "ConvertToTimeFormat"
B4X:
'converts milliseconds to m:ss format.
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
now i want to change for example 3:05 to Milliseconds
some thing like this
B4X:
Sub ConvertToMediaFormat(Time As String) As Int
  
End Sub
thank u
 
Last edited:

ArminKH

Well-Known Member
I'm sure you can do it on your own!
Think about how many seconds are in a minute and how many milliseconds are in a second and you should find the answer.
yes,solved thank u
B4X:
Sub ConvertToMediaFormat(Time As String) As Int
    Dim t() As String = Regex.Split(":",Time)
        Return ((t(0) * 60) + t(1)) * 1000
End Sub
 
Upvote 0
Top