display correct playback speed for media

This commit is contained in:
Akinwale Ariwodola 2020-09-04 12:50:22 +01:00
parent 45be7f2c9b
commit c1106d7186
2 changed files with 16 additions and 0 deletions

View file

@ -728,6 +728,7 @@ public class FileViewFragment extends BaseFragment implements
}
}
updatePlaybackSpeedView(root);
loadAndScheduleDurations();
}
@ -1184,6 +1185,16 @@ public class FileViewFragment extends BaseFragment implements
commentsList.setLayoutManager(commentsListLLM);
}
private void updatePlaybackSpeedView(View root) {
if (root != null) {
PlayerView playerView = root.findViewById(R.id.file_view_exoplayer_view);
TextView textPlaybackSpeed = playerView.findViewById(R.id.player_playback_speed_label);
textPlaybackSpeed.setText(MainActivity.appPlayer != null && MainActivity.appPlayer.getPlaybackParameters() != null ?
Helper.getDisplayValueForPlaybackSpeed((double) MainActivity.appPlayer.getPlaybackParameters().speed) :
DEFAULT_PLAYBACK_SPEED);
}
}
private void deleteCurrentClaim() {
if (claim != null) {
Helper.setViewVisibility(layoutDisplayArea, View.INVISIBLE);

View file

@ -103,6 +103,11 @@ public final class Helper {
}
}
public static String getDisplayValueForPlaybackSpeed(Double speed) {
DecimalFormat formatter = new DecimalFormat("0.##");
return String.format("%sx", formatter.format(speed));
}
public static String capitalize(String value) {
StringBuilder sb = new StringBuilder();
boolean capitalizeNext = true;