From 0ac61168cfb6dee32940b53e2dabc2df26c94b44 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 21 Nov 2022 15:24:48 +0100 Subject: [PATCH 1/2] remove load interval size --- .../main/java/com/github/libretube/util/PlayerHelper.kt | 6 ------ app/src/main/res/xml/audio_video_settings.xml | 9 --------- 2 files changed, 15 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt index 77ed8f8a4..0d3963e8f 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerHelper.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerHelper.kt @@ -256,12 +256,6 @@ object PlayerHelper { false ) - val progressiveLoadingIntervalSize: String - get() = PreferenceHelper.getString( - PreferenceKeys.PROGRESSIVE_LOADING_INTERVAL_SIZE, - "64" - ) - val autoPlayEnabled: Boolean get() = PreferenceHelper.getBoolean( PreferenceKeys.AUTO_PLAY, diff --git a/app/src/main/res/xml/audio_video_settings.xml b/app/src/main/res/xml/audio_video_settings.xml index abf852357..f3533a560 100644 --- a/app/src/main/res/xml/audio_video_settings.xml +++ b/app/src/main/res/xml/audio_video_settings.xml @@ -76,15 +76,6 @@ android:title="@string/hls_instead_of_dash" app:key="use_hls" /> - - From 7c3780137dad5f68484f1f740d06afbda7329b9a Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 21 Nov 2022 15:34:43 +0100 Subject: [PATCH 2/2] fix the watch position pref --- .../libretube/services/BackgroundMode.kt | 2 +- .../libretube/ui/fragments/PlayerFragment.kt | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index 64ff18843..1dbf786e6 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -131,7 +131,7 @@ class BackgroundMode : Service() { streamItem.url?.toID()?.let { playNextVideo(it) } } - updateWatchPosition() + if (PlayerHelper.watchPositionsEnabled) updateWatchPosition() } catch (e: Exception) { onDestroy() } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index df6b01704..eadf776b6 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -501,11 +501,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { override fun onDestroy() { super.onDestroy() try { - // clear the playing queue - PlayingQueue.resetToDefaults() - saveWatchPosition() + + // clear the playing queue and release the player + PlayingQueue.resetToDefaults() nowPlayingNotification.destroySelfAndPlayer() + activity?.requestedOrientation = if ((activity as MainActivity).autoRotationEnabled) { ActivityInfo.SCREEN_ORIENTATION_USER @@ -520,16 +521,16 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { // save the watch position if video isn't finished and option enabled private fun saveWatchPosition() { if (!PlayerHelper.watchPositionsEnabled) return - if (exoPlayer.currentPosition != exoPlayer.duration) { - val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition) - query { - Database.watchPositionDao().insertAll(watchPosition) - } - } else if (PlayerHelper.watchPositionsEnabled) { - // delete watch position if video has ended - query { - Database.watchPositionDao().deleteById(videoId!!) - } + Log.e( + "watchpositions", + PreferenceHelper.getBoolean( + PreferenceKeys.WATCH_POSITION_TOGGLE, + true + ).toString() + ) + val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition) + query { + Database.watchPositionDao().insertAll(watchPosition) } }