Hide prev/next for single item queue, Fullscreen next/prev button show/hide, Bypass loop for next controls

This commit is contained in:
Kelvin 2023-12-08 11:17:36 +01:00
parent 1c0cfa89a3
commit bc00b12b8c
3 changed files with 17 additions and 10 deletions

View File

@ -468,7 +468,7 @@ class VideoDetailView : ConstraintLayout {
nextVideo(); nextVideo();
}; };
_player.onDatasourceError.subscribe(::onDataSourceError); _player.onDatasourceError.subscribe(::onDataSourceError);
_player.onNext.subscribe { nextVideo(true, true) }; _player.onNext.subscribe { nextVideo(true, true, true) };
_player.onPrevious.subscribe { prevVideo(true) }; _player.onPrevious.subscribe { prevVideo(true) };
_minimize_controls_play.setOnClickListener { handlePlay(); }; _minimize_controls_play.setOnClickListener { handlePlay(); };
@ -546,7 +546,7 @@ class VideoDetailView : ConstraintLayout {
MediaControlReceiver.onLowerVolumeReceived.subscribe(this) { handleLowerVolume() }; MediaControlReceiver.onLowerVolumeReceived.subscribe(this) { handleLowerVolume() };
MediaControlReceiver.onPlayReceived.subscribe(this) { handlePlay() }; MediaControlReceiver.onPlayReceived.subscribe(this) { handlePlay() };
MediaControlReceiver.onPauseReceived.subscribe(this) { handlePause() }; MediaControlReceiver.onPauseReceived.subscribe(this) { handlePause() };
MediaControlReceiver.onNextReceived.subscribe(this) { nextVideo(true) }; MediaControlReceiver.onNextReceived.subscribe(this) { nextVideo(true, true, true) };
MediaControlReceiver.onPreviousReceived.subscribe(this) { prevVideo(true) }; MediaControlReceiver.onPreviousReceived.subscribe(this) { prevVideo(true) };
MediaControlReceiver.onCloseReceived.subscribe(this) { MediaControlReceiver.onCloseReceived.subscribe(this) {
Logger.i(TAG, "MediaControlReceiver.onCloseReceived") Logger.i(TAG, "MediaControlReceiver.onCloseReceived")
@ -1332,6 +1332,7 @@ class VideoDetailView : ConstraintLayout {
if(video.isLive && video.live == null && !video.video.videoSources.any()) if(video.isLive && video.live == null && !video.video.videoSources.any())
startLiveTry(video); startLiveTry(video);
_player.updateNextPrevious();
updateMoreButtons(); updateMoreButtons();
} }
fun loadLiveChat(video: IPlatformVideoDetails) { fun loadLiveChat(video: IPlatformVideoDetails) {
@ -1551,9 +1552,9 @@ class VideoDetailView : ConstraintLayout {
} }
} }
fun nextVideo(forceLoop: Boolean = false, withoutRemoval: Boolean = false): Boolean { fun nextVideo(forceLoop: Boolean = false, withoutRemoval: Boolean = false, bypassVideoLoop: Boolean = false): Boolean {
Logger.i(TAG, "nextVideo") Logger.i(TAG, "nextVideo")
var next = StatePlayer.instance.nextQueueItem(withoutRemoval || _player.duration < 100 || (_player.position.toFloat() / _player.duration) < 0.9); var next = StatePlayer.instance.nextQueueItem(withoutRemoval || _player.duration < 100 || (_player.position.toFloat() / _player.duration) < 0.9, bypassVideoLoop);
if(next == null && forceLoop) if(next == null && forceLoop)
next = StatePlayer.instance.restartQueue(); next = StatePlayer.instance.restartQueue();
if(next != null) { if(next != null) {

View File

@ -375,6 +375,9 @@ class StatePlayer {
fun getPrevQueueItem(forceLoop: Boolean = false) : IPlatformVideo? { fun getPrevQueueItem(forceLoop: Boolean = false) : IPlatformVideo? {
synchronized(_queue) { synchronized(_queue) {
if(_queue.size == 1)
return null;
val shuffledQueue = _queueShuffled; val shuffledQueue = _queueShuffled;
val queue = if (queueShuffle && shuffledQueue != null) { val queue = if (queueShuffle && shuffledQueue != null) {
shuffledQueue; shuffledQueue;
@ -386,7 +389,7 @@ class StatePlayer {
if(_queuePosition == -1 && queue.isNotEmpty()) if(_queuePosition == -1 && queue.isNotEmpty())
return queue[0]; return queue[0];
//Standard Behavior //Standard Behavior
if(_queuePosition - 1 > 0) if(_queuePosition - 1 >= 0)
return queue[_queuePosition - 1]; return queue[_queuePosition - 1];
//Repeat Behavior (End of queue) //Repeat Behavior (End of queue)
if(_queuePosition - 1 < 0 && queue.isNotEmpty() && (forceLoop || queueRepeat)) if(_queuePosition - 1 < 0 && queue.isNotEmpty() && (forceLoop || queueRepeat))
@ -395,9 +398,10 @@ class StatePlayer {
return null; return null;
} }
fun getNextQueueItem(forceLoop: Boolean = false) : IPlatformVideo? { fun getNextQueueItem(forceLoop: Boolean = false) : IPlatformVideo? {
if(loopVideo)
return currentVideo;
synchronized(_queue) { synchronized(_queue) {
if(_queue.size == 1)
return null;
val shuffledQueue = _queueShuffled; val shuffledQueue = _queueShuffled;
val queue = if (queueShuffle && shuffledQueue != null) { val queue = if (queueShuffle && shuffledQueue != null) {
shuffledQueue; shuffledQueue;
@ -420,11 +424,11 @@ class StatePlayer {
fun restartQueue() : IPlatformVideo? { fun restartQueue() : IPlatformVideo? {
synchronized(_queue) { synchronized(_queue) {
_queuePosition = -1; _queuePosition = -1;
return nextQueueItem(); return nextQueueItem(false, true);
} }
}; };
fun nextQueueItem(withoutRemoval: Boolean = false) : IPlatformVideo? { fun nextQueueItem(withoutRemoval: Boolean = false, bypassVideoLoop: Boolean = false) : IPlatformVideo? {
if(loopVideo) if(loopVideo && !bypassVideoLoop)
return currentVideo; return currentVideo;
synchronized(_queue) { synchronized(_queue) {
if (_queue.isEmpty()) if (_queue.isEmpty())

View File

@ -325,7 +325,9 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
val vidPrev = StatePlayer.instance.getPrevQueueItem(true); val vidPrev = StatePlayer.instance.getPrevQueueItem(true);
val vidNext = StatePlayer.instance.getNextQueueItem(true); val vidNext = StatePlayer.instance.getNextQueueItem(true);
_buttonNext.visibility = if (vidNext != null) View.VISIBLE else View.GONE _buttonNext.visibility = if (vidNext != null) View.VISIBLE else View.GONE
_buttonNext_fullscreen.visibility = if (vidNext != null) View.VISIBLE else View.GONE
_buttonPrevious.visibility = if (vidPrev != null) View.VISIBLE else View.GONE _buttonPrevious.visibility = if (vidPrev != null) View.VISIBLE else View.GONE
_buttonPrevious_fullscreen.visibility = if (vidPrev != null) View.VISIBLE else View.GONE
} }
private val _currentChapterUpdateInterval: Long = 1000L / Settings.instance.playback.getChapterUpdateFrames(); private val _currentChapterUpdateInterval: Long = 1000L / Settings.instance.playback.getChapterUpdateFrames();