From bbdb1d7ad31fb570fa00dbf3017b25792958f7a6 Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Wed, 24 Aug 2022 03:10:06 +0200 Subject: [PATCH] Add toggle to disable autoplay Fixes #57 --- .../cloudstream3/ui/player/CS3IPlayer.kt | 21 +++++++++++++++++-- app/src/main/res/values/strings.xml | 5 +++++ app/src/main/res/xml/settings_player.xml | 6 ++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt index 0eb72f19..5f6ef921 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt @@ -6,6 +6,7 @@ import android.os.Handler import android.os.Looper import android.util.Log import android.widget.FrameLayout +import androidx.preference.PreferenceManager import com.google.android.exoplayer2.* import com.google.android.exoplayer2.database.StandaloneDatabaseProvider import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource @@ -742,7 +743,15 @@ class CS3IPlayer : IPlayer { } Player.STATE_ENDED -> { - handleEvent(CSPlayerEvent.NextEpisode) + // Only play next episode if autoplay is on (default) + if (PreferenceManager.getDefaultSharedPreferences(context) + ?.getBoolean( + context.getString(com.lagradost.cloudstream3.R.string.autoplay_next_key), + true + ) == true + ) { + handleEvent(CSPlayerEvent.NextEpisode) + } } Player.STATE_BUFFERING -> { updatedTime() @@ -780,7 +789,15 @@ class CS3IPlayer : IPlayer { } Player.STATE_ENDED -> { - handleEvent(CSPlayerEvent.NextEpisode) + // Only play next episode if autoplay is on (default) + if (PreferenceManager.getDefaultSharedPreferences(context) + ?.getBoolean( + context.getString(com.lagradost.cloudstream3.R.string.autoplay_next_key), + true + ) == true + ) { + handleEvent(CSPlayerEvent.NextEpisode) + } } Player.STATE_BUFFERING -> { updatedTime() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4430d224..1b47b180 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -29,6 +29,7 @@ double_tap_pause_enabled_key double_tap_seek_time_key swipe_vertical_enabled_key + autoplay_next_key display_sub_key show_fillers_key show_trailers_key @@ -223,6 +224,10 @@ Swipe left or right to control time in the videoplayer Swipe to change settings Swipe on the left or right side to change brightness or volume + + Autoplay next episode + Start the next episode when the current one ends + Double tap to seek Double tap to pause Player seek amount diff --git a/app/src/main/res/xml/settings_player.xml b/app/src/main/res/xml/settings_player.xml index d98f506f..a7e36488 100644 --- a/app/src/main/res/xml/settings_player.xml +++ b/app/src/main/res/xml/settings_player.xml @@ -58,6 +58,12 @@ android:title="@string/swipe_to_change_settings" android:summary="@string/swipe_to_change_settings_des" app:defaultValue="true" /> +