Merge pull request #1961 from Bnyro/master

Fix the watch position pref
This commit is contained in:
Bnyro 2022-11-21 15:35:24 +01:00 committed by GitHub
commit c2f95a5548
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 29 deletions

View File

@ -131,7 +131,7 @@ class BackgroundMode : Service() {
streamItem.url?.toID()?.let { playNextVideo(it) }
}
updateWatchPosition()
if (PlayerHelper.watchPositionsEnabled) updateWatchPosition()
} catch (e: Exception) {
onDestroy()
}

View File

@ -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)
}
}

View File

@ -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,

View File

@ -76,15 +76,6 @@
android:title="@string/hls_instead_of_dash"
app:key="use_hls" />
<ListPreference
android:icon="@drawable/ic_loading"
app:defaultValue="64"
app:entries="@array/loadingInterval"
app:entryValues="@array/loadingIntervalValues"
app:key="progressive_loading_interval"
app:summary="@string/progressive_load_interval_summary"
app:title="@string/progressive_load_interval" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/background_mode">