mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
Merge pull request #6032 from Bnyro/master
fix: repeat current doesn't work if autoplay disabled
This commit is contained in:
commit
8f7fd2f05a
@ -45,7 +45,6 @@ import com.github.libretube.extensions.seekBy
|
||||
import com.github.libretube.extensions.togglePlayPauseState
|
||||
import com.github.libretube.extensions.updateParameters
|
||||
import com.github.libretube.obj.VideoStats
|
||||
import com.github.libretube.util.PlayingQueue
|
||||
import com.github.libretube.util.TextUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -357,18 +356,9 @@ object PlayerHelper {
|
||||
true
|
||||
)
|
||||
|
||||
fun shouldPlayNextVideo(isPlaylist: Boolean = false): Boolean {
|
||||
// if there is no next video, it obviously should not be played
|
||||
if (!PlayingQueue.hasNext()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return autoPlayEnabled || (
|
||||
isPlaylist && PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.AUTOPLAY_PLAYLISTS,
|
||||
false
|
||||
)
|
||||
)
|
||||
fun isAutoPlayEnabled(isPlaylist: Boolean = false): Boolean {
|
||||
return autoPlayEnabled || (isPlaylist && PreferenceHelper
|
||||
.getBoolean(PreferenceKeys.AUTOPLAY_PLAYLISTS, false))
|
||||
}
|
||||
|
||||
private val handleAudioFocus
|
||||
|
@ -131,7 +131,7 @@ class OnlinePlayerService : LifecycleService() {
|
||||
|
||||
when (state) {
|
||||
Player.STATE_ENDED -> {
|
||||
if (PlayerHelper.shouldPlayNextVideo(playlistId != null) && !isTransitioning) playNextVideo()
|
||||
if (!isTransitioning) playNextVideo()
|
||||
}
|
||||
|
||||
Player.STATE_IDLE -> {
|
||||
@ -353,6 +353,10 @@ class OnlinePlayerService : LifecycleService() {
|
||||
return
|
||||
}
|
||||
|
||||
saveWatchPosition()
|
||||
|
||||
if (!PlayerHelper.isAutoPlayEnabled(playlistId != null)) return
|
||||
|
||||
val nextVideo = nextId ?: PlayingQueue.getNext() ?: return
|
||||
|
||||
// play new video on background
|
||||
|
@ -294,7 +294,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
|
||||
// check if video has ended, next video is available and autoplay is enabled/the video is part of a played playlist.
|
||||
if (playbackState == Player.STATE_ENDED) {
|
||||
if (!isTransitioning && PlayerHelper.shouldPlayNextVideo(playlistId != null)) {
|
||||
if (!isTransitioning) {
|
||||
isTransitioning = true
|
||||
if (PlayerHelper.autoPlayCountdown) {
|
||||
showAutoPlayCountdown()
|
||||
@ -995,13 +995,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
return
|
||||
}
|
||||
|
||||
if (!PlayerHelper.isAutoPlayEnabled(playlistId != null)) return
|
||||
|
||||
// save the current watch position before starting the next video
|
||||
saveWatchPosition()
|
||||
|
||||
val nextVideoId = nextId ?: PlayingQueue.getNext() ?: return
|
||||
|
||||
videoId = nextId ?: PlayingQueue.getNext() ?: return
|
||||
isTransitioning = true
|
||||
videoId = nextVideoId
|
||||
|
||||
// fix: if the fragment is recreated, play the current video, and not the initial one
|
||||
arguments?.run {
|
||||
|
Loading…
x
Reference in New Issue
Block a user