Skip to content

Commit

Permalink
fix reading old vod position
Browse files Browse the repository at this point in the history
(cherry picked from commit ae30bfa)
  • Loading branch information
crackededed committed Aug 5, 2023
1 parent 1221091 commit 4bd6b93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ android {
applicationId = "com.github.andreyasadchy.xtra"
minSdk = 21
targetSdk = 33
versionCode = 204
versionName = "2.24.1"
versionCode = 205
versionName = "2.24.2"
resourceConfigurations += listOf("ar", "de", "en", "es", "fr", "in", "ja", "pt-rBR", "ru", "tr")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ class PlaybackService : MediaSessionService() {
session.player.setPlaybackSpeed(prefs().getFloat(C.PLAYER_SPEED, 1f))
session.player.prepare()
session.player.playWhenReady = true
session.player.seekTo(customCommand.customExtras.getLong(PLAYBACK_POSITION))
session.player.seekTo(savedPosition?.let { if (it.id == item.id?.toLongOrNull()) it.position else null }
?: customCommand.customExtras.getLong(PLAYBACK_POSITION))
}
}
Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
Expand Down Expand Up @@ -464,7 +465,9 @@ class PlaybackService : MediaSessionService() {
session.player.setPlaybackSpeed(prefs().getFloat(C.PLAYER_SPEED, 1f))
session.player.prepare()
session.player.playWhenReady = true
session.player.seekTo(if (prefs.getBoolean(C.PLAYER_USE_VIDEOPOSITIONS, true)) item.lastWatchPosition ?: 0 else 0)
session.player.seekTo(if (prefs.getBoolean(C.PLAYER_USE_VIDEOPOSITIONS, true)) {
savedPosition?.let { if (it.id == item.id.toLong()) it.position else null } ?: item.lastWatchPosition ?: 0
} else 0)
}
Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
}
Expand Down Expand Up @@ -886,10 +889,15 @@ class PlaybackService : MediaSessionService() {
when (item) {
is Video -> {
item.id?.toLongOrNull()?.let { id ->
playerRepository.saveVideoPosition(VideoPosition(id, player.currentPosition))
val position = VideoPosition(id, player.currentPosition)
savedPosition = position
playerRepository.saveVideoPosition(position)
}
}
is OfflineVideo -> offlineRepository.updateVideoPosition(item.id, player.currentPosition)
is OfflineVideo -> {
savedPosition = VideoPosition(item.id.toLong(), player.currentPosition)
offlineRepository.updateVideoPosition(item.id, player.currentPosition)
}
}
}
}
Expand Down Expand Up @@ -919,6 +927,7 @@ class PlaybackService : MediaSessionService() {
private var mediaItem: MediaItem? = null
private var headers: HashMap<String, String>? = null
private var playbackPosition: Long = 0
private var savedPosition: VideoPosition? = null

private var usingPlaylist = false
private var usingAutoQuality = false
Expand Down

0 comments on commit 4bd6b93

Please sign in to comment.