我有一个 mp3 文件,我的应用程序必须寻找该 mp3 文件的某个选定时间,然后从那里开始播放。
我通过这种方法将我的字符串时间转换为 int 值
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;
}
注意:我的刺痛是这样的,这5:12.201
意味着 5 分 12 秒和 201 毫秒。
我从MP3 Audio Editor
应用程序(适用于 Windows)中获得了这些时间,并使用应用程序检查了主题KMPlayer
(适用于 Windows)。这些时间对他们俩都是正确的。
但是在我的应用程序中,当我寻找MediaPlayer
到那个时间时,音频不会从我选择的位置开始。 (时间正确,但声音不同。)
我认为那MediaPlayer
不正确地寻求那个时间。所以我getCurrentPosition()
在玩之前通过调用来检查当前位置,但返回值和搜索值是相同的。
我对此一无所知。
编辑:
我的问题不是时间转换。
我正确地转换并寻找到那里,但它播放了当时没有预料到的东西。
这意味着 KMPlayer 和 Android 中的时间是不同的。
我的问题是方式?又该如何解决呢?