我目前正在onProgress
中显示进度,如下所示:
@Override
public void onProgress(String message) {
Pattern pattern = Pattern.compile("time=([\\d\\w:]{8}[\\w.][\\d]+)");
if (message.contains("speed")) {
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
String tempTime = String.valueOf(matcher.group(1));
String[] arrayTime = tempTime.split("[:|.]");
long currentTime = TimeUnit.HOURS.toMillis(Long.parseLong(arrayTime[0]))
+ TimeUnit.MINUTES.toMillis(Long.parseLong(arrayTime[1]))
+ TimeUnit.SECONDS.toMillis(Long.parseLong(arrayTime[2]))
+ Long.parseLong(arrayTime[3]);
//Length of video in milliseconds
long timeToExportInMillis = rightThumbTimeRef - leftThumbTimeRef;
//Calculate percentage
long percent = 100 * currentTime / timeToExportInMillis;
//Set percentage to TextView
percentText.setText(percent + " %");
}
}
}
我的问题是进度会像这样更新:
0 - 9 - 17 - 30 - 38
等(直到100)
我想显示进度而不跳过值,例如:
0 - 1 - 2 - 3 - 4
等(直到100)
我什至不确定是否可行,因为currentTime
(如上)的更新取决于FFmpeg的进度输出,任何建议都将不胜感激。