Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay

This commit is contained in:
Koen 2024-01-11 12:59:18 +01:00
commit fdd7e32dd8
3 changed files with 23 additions and 0 deletions

View file

@ -649,6 +649,14 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
};
return true;
}
else if(StatePlatform.instance.hasEnabledPlaylistClient(url)) {
navigate(_fragMainPlaylist, url);
lifecycleScope.launch {
delay(100);
_fragVideoDetail.minimizeVideoDetail();
};
return true;
}
return false;
}
fun handleContent(file: String, mime: String? = null): Boolean {

View file

@ -841,6 +841,7 @@ class StatePlatform {
return urls;
}
fun hasEnabledPlaylistClient(url: String) : Boolean = getEnabledClients().any { it.isPlaylistUrl(url) };
fun getPlaylistClientOrNull(url: String): IPlatformClient? = getEnabledClients().find { it.isPlaylistUrl(url) }
fun getPlaylistClient(url: String): IPlatformClient = getEnabledClients().find { it.isPlaylistUrl(url) }
?: throw NoPlatformClientException("No client enabled that supports this playlist url (${url})");

View file

@ -361,6 +361,12 @@ class StatePlayer {
if (queueShuffle) {
removeFromShuffledQueue(video);
}
if(currentVideo != null) {
val newPos = _queue.indexOfFirst { it.url == currentVideo?.url };
if(newPos >= 0)
_queuePosition = newPos;
}
}
onQueueChanged.emit(shouldSwapCurrentItem);
@ -407,6 +413,12 @@ class StatePlayer {
if(_queue.size == 1) {
return null;
}
if(_queue.size <= _queuePosition && currentVideo != null) {
//Out of sync position
val newPos = _queue.indexOfFirst { it.url == currentVideo?.url }
if(newPos != -1)
_queuePosition = newPos;
}
val shuffledQueue = _queueShuffled;
val queue = if (queueShuffle && shuffledQueue != null) {
@ -421,6 +433,8 @@ class StatePlayer {
}
//Standard Behavior
if(_queuePosition - 1 >= 0) {
if(queue.size <= _queuePosition)
return null;
return queue[_queuePosition - 1];
}
//Repeat Behavior (End of queue)