Add toggle to disable autoplay

Fixes #57
This commit is contained in:
Blatzar 2022-08-24 03:10:06 +02:00
parent 92dbbf86b2
commit bbdb1d7ad3
3 changed files with 30 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.preference.PreferenceManager
import com.google.android.exoplayer2.* import com.google.android.exoplayer2.*
import com.google.android.exoplayer2.database.StandaloneDatabaseProvider import com.google.android.exoplayer2.database.StandaloneDatabaseProvider
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource
@ -742,7 +743,15 @@ class CS3IPlayer : IPlayer {
} }
Player.STATE_ENDED -> { 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 -> { Player.STATE_BUFFERING -> {
updatedTime() updatedTime()
@ -780,7 +789,15 @@ class CS3IPlayer : IPlayer {
} }
Player.STATE_ENDED -> { 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 -> { Player.STATE_BUFFERING -> {
updatedTime() updatedTime()

View file

@ -29,6 +29,7 @@
<string name="double_tap_pause_enabled_key" translatable="false">double_tap_pause_enabled_key</string> <string name="double_tap_pause_enabled_key" translatable="false">double_tap_pause_enabled_key</string>
<string name="double_tap_seek_time_key" translatable="false">double_tap_seek_time_key</string> <string name="double_tap_seek_time_key" translatable="false">double_tap_seek_time_key</string>
<string name="swipe_vertical_enabled_key" translatable="false">swipe_vertical_enabled_key</string> <string name="swipe_vertical_enabled_key" translatable="false">swipe_vertical_enabled_key</string>
<string name="autoplay_next_key" translatable="false">autoplay_next_key</string>
<string name="display_sub_key" translatable="false">display_sub_key</string> <string name="display_sub_key" translatable="false">display_sub_key</string>
<string name="show_fillers_key" translatable="false">show_fillers_key</string> <string name="show_fillers_key" translatable="false">show_fillers_key</string>
<string name="show_trailers_key" translatable="false">show_trailers_key</string> <string name="show_trailers_key" translatable="false">show_trailers_key</string>
@ -223,6 +224,10 @@
<string name="swipe_to_seek_settings_des">Swipe left or right to control time in the videoplayer</string> <string name="swipe_to_seek_settings_des">Swipe left or right to control time in the videoplayer</string>
<string name="swipe_to_change_settings">Swipe to change settings</string> <string name="swipe_to_change_settings">Swipe to change settings</string>
<string name="swipe_to_change_settings_des">Swipe on the left or right side to change brightness or volume</string> <string name="swipe_to_change_settings_des">Swipe on the left or right side to change brightness or volume</string>
<string name="autoplay_next_settings">Autoplay next episode</string>
<string name="autoplay_next_settings_des">Start the next episode when the current one ends</string>
<string name="double_tap_to_seek_settings">Double tap to seek</string> <string name="double_tap_to_seek_settings">Double tap to seek</string>
<string name="double_tap_to_pause_settings">Double tap to pause</string> <string name="double_tap_to_pause_settings">Double tap to pause</string>
<string name="double_tap_to_seek_amount_settings">Player seek amount</string> <string name="double_tap_to_seek_amount_settings">Player seek amount</string>

View file

@ -58,6 +58,12 @@
android:title="@string/swipe_to_change_settings" android:title="@string/swipe_to_change_settings"
android:summary="@string/swipe_to_change_settings_des" android:summary="@string/swipe_to_change_settings_des"
app:defaultValue="true" /> app:defaultValue="true" />
<SwitchPreference
android:icon="@drawable/ic_baseline_skip_next_24"
app:key="@string/autoplay_next_key"
android:title="@string/autoplay_next_settings"
android:summary="@string/autoplay_next_settings_des"
app:defaultValue="true" />
<SwitchPreference <SwitchPreference
android:icon="@drawable/ic_baseline_touch_app_24" android:icon="@drawable/ic_baseline_touch_app_24"
app:key="@string/double_tap_enabled_key" app:key="@string/double_tap_enabled_key"