I have a mp3 file and my application must seek to some selected time of that mp3 file then start playing from there.
I convert my string time by this method to int value
private static int convert(String time) {
int quoteInd = time.indexOf(":");
int pointInd = time.indexOf(".");
int min = Integer.valueOf(time.substring(0, quoteInd));
int sec = Integer.valueOf(time.substring(++quoteInd, pointInd));
int mil = Integer.valueOf(time.substring(++pointInd, time.length()));
return (((min * 60) + sec) * 1000) + mil;
}
Note: my stings is like this 5:12.201
that means 5 mins and 12 seconds and 201 milliseconds.
I getted these times from MP3 Audio Editor
application (it's for windows) and I checked theme with KMPlayer
application (it's for windows). And these times was correct on both of them.
But in my app when I seek my MediaPlayer
to that time, audio doesn't start from my selected position. (time is correct but sound is different.)
I thought that the MediaPlayer
doesn't seek to that time correctly. So I checked current position by calling getCurrentPosition()
before playing but returned value and seeked value was same.
I haven't any Idea about It.
Edit:
My problem is NOT time converting.
I convert and seek to there correctly but it play something that not expected in that time.
It means timing in KMPlayer and Android are differents.
My question is Way? and How can is solve it?