Skip to content

Commit

Permalink
Pause video playback while dialog is open
Browse files Browse the repository at this point in the history
  • Loading branch information
folkemat committed Jan 9, 2024
1 parent 8da0a3a commit 8cd14ef
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ public static String msToMinutesAndSecondsString(final long ms) {
return String.format(Locale.US, "%d:%02d", mins, secs);
}
private void openSpeedSettingDialog(final Context context) {
// Pause video playback before opening the dialog
mVideoPlayer.setPlayWhenReady(false);

final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
builder.setTitle(R.string.video_speed_instruction);

Expand Down Expand Up @@ -527,8 +530,18 @@ public void onStopTrackingTouch(final SeekBar seekBar) { }
mCurrentPlaybackSpeed = 0.01f * (speedSeekBar.getProgress() + 1);
mVideoPlayer.setPlaybackSpeed(mCurrentPlaybackSpeed);
mSpeedTextView.setText(String.format(Locale.US, "(%.2fx)", mCurrentPlaybackSpeed));
// Resume video playback when dialog is dismissed
mVideoPlayer.setPlayWhenReady(true);
});
builder.setNegativeButton("Cancel", (dialog, which) -> {
// Resume video playback when dialog is dismissed
mVideoPlayer.setPlayWhenReady(true);
});

builder.setOnCancelListener(dialog -> {
// Resume video playback when dialog is canceled
mVideoPlayer.setPlayWhenReady(true);
});
builder.setNegativeButton("Cancel", null);

builder.show();
}
Expand Down

0 comments on commit 8cd14ef

Please sign in to comment.