diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index 8cff78f24..42cf5c619 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -577,8 +577,6 @@ class PlayerFragment : BaseFragment() { playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit) playerBinding.exoTitle.visibility = View.VISIBLE - scaleControls(1.3F) - val mainActivity = activity as MainActivity if (!autoRotationEnabled) { // different orientations of the video are only available when auto rotation is disabled @@ -613,8 +611,6 @@ class PlayerFragment : BaseFragment() { playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen) playerBinding.exoTitle.visibility = View.INVISIBLE - scaleControls(1F) - if (!autoRotationEnabled) { // switch back to portrait mode if auto rotation disabled val mainActivity = activity as MainActivity @@ -624,11 +620,6 @@ class PlayerFragment : BaseFragment() { Globals.IS_FULL_SCREEN = false } - private fun scaleControls(scaleFactor: Float) { - playerBinding.exoPlayPause.scaleX = scaleFactor - playerBinding.exoPlayPause.scaleY = scaleFactor - } - private fun toggleDescription() { if (binding.descLinLayout.isVisible) { // hide the description and chapters @@ -766,7 +757,18 @@ class PlayerFragment : BaseFragment() { * set the videoId of the next stream for autoplay */ private fun setNextStream() { - nextStreamId = streams.relatedStreams!![0].url.toID() + // don't play a video if it got played before already + var index = 0 + while (nextStreamId == null || nextStreamId == videoId!! || + ( + videoIds.contains(nextStreamId) && + videoIds.indexOf(videoId) > videoIds.indexOf(nextStreamId) + ) + ) { + nextStreamId = streams.relatedStreams!![index].url.toID() + if (index + 1 < streams.relatedStreams!!.size) index += 1 + else break + } if (playlistId == null) return if (!this::autoPlayHelper.isInitialized) autoPlayHelper = AutoPlayHelper(playlistId!!) // search for the next videoId in the playlist @@ -835,17 +837,16 @@ class PlayerFragment : BaseFragment() { // used for autoplay and skipping to next video private fun playNextVideo() { + if (nextStreamId == null) return // check whether there is a new video in the queue // by making sure that the next and the current video aren't the same saveWatchPosition() // forces the comments to reload for the new video commentsLoaded = false binding.commentsRecView.adapter = null - if (videoId != nextStreamId) { - // save the id of the next stream as videoId and load the next video - videoId = nextStreamId - playVideo() - } + // save the id of the next stream as videoId and load the next video + videoId = nextStreamId + playVideo() } private fun prepareExoPlayerView() {