diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-06-17 14:58:39 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-06-17 14:58:39 +0000 |
commit | c4953363601ceec4185c020f78c959fe3812d0ca (patch) | |
tree | 5b27a13902cd8daa62565c0255db997f01e96e40 | |
parent | 9b7e1e863af66d8b95bfa750c24e97760dfe8f14 (diff) | |
download | infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.tar infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.tar.gz infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.tar.bz2 infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.tar.lz infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.tar.xz infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.tar.zst infinity-for-reddit-c4953363601ceec4185c020f78c959fe3812d0ca.zip |
Fix https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/1674 the audio does not stop after closing a video.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 891bb99f..6be51742 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -31,6 +31,7 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.Toast; +import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.OptIn; import androidx.appcompat.app.ActionBar; @@ -347,6 +348,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe } binding.getRoot().setOnDragDismissedListener(dragDirection -> { + player.stop(); int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down; finish(); overridePendingTransition(0, slide); @@ -648,6 +650,15 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe player.setMediaSource(new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(mVideoUri))); preparePlayer(savedInstanceState); } + + getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) { + @Override + public void handleOnBackPressed() { + player.stop(); + setEnabled(false); + getOnBackPressedDispatcher().onBackPressed(); + } + }); } private void preparePlayer(Bundle savedInstanceState) { |