show the duration of the currently recorded video

This commit is contained in:
tibbi
2016-06-12 22:23:40 +02:00
parent 5ad1e2ad71
commit faa72cf25c
3 changed files with 59 additions and 0 deletions

View File

@@ -77,4 +77,20 @@ public class Utils {
final String[] paths = {path};
MediaScannerConnection.scanFile(context, paths, null, null);
}
public static String formatSeconds(int duration) {
final StringBuilder sb = new StringBuilder(8);
final int hours = duration / (60 * 60);
final int minutes = (duration % (60 * 60)) / 60;
final int seconds = ((duration % (60 * 60)) % 60);
if (duration > 3600000) {
sb.append(String.format(Locale.getDefault(), "%02d", hours)).append(":");
}
sb.append(String.format(Locale.getDefault(), "%02d", minutes));
sb.append(":").append(String.format(Locale.getDefault(), "%02d", seconds));
return sb.toString();
}
}