Changed queue behaviour to be more like VLC.

This commit is contained in:
Koen 2023-09-27 10:44:30 +02:00
parent a51cdcd6ec
commit bc83f9b274
6 changed files with 16 additions and 3 deletions

View File

@ -170,6 +170,7 @@ class ChannelFragment : MainFragment() {
adapter.onChannelClicked.subscribe { c -> fragment.navigate<ChannelFragment>(c) } adapter.onChannelClicked.subscribe { c -> fragment.navigate<ChannelFragment>(c) }
adapter.onContentClicked.subscribe { v, _ -> adapter.onContentClicked.subscribe { v, _ ->
if(v is IPlatformVideo) { if(v is IPlatformVideo) {
StatePlayer.instance.clearQueue();
fragment.navigate<VideoDetailFragment>(v).maximizeVideoDetail(); fragment.navigate<VideoDetailFragment>(v).maximizeVideoDetail();
} else if (v is IPlatformPlaylist) { } else if (v is IPlatformPlaylist) {
fragment.navigate<PlaylistFragment>(v); fragment.navigate<PlaylistFragment>(v);
@ -192,7 +193,10 @@ class ChannelFragment : MainFragment() {
} }
adapter.onContentUrlClicked.subscribe { url, contentType -> adapter.onContentUrlClicked.subscribe { url, contentType ->
when(contentType) { when(contentType) {
ContentType.MEDIA -> fragment.navigate<VideoDetailFragment>(url).maximizeVideoDetail(); ContentType.MEDIA -> {
StatePlayer.instance.clearQueue();
fragment.navigate<VideoDetailFragment>(url).maximizeVideoDetail();
};
ContentType.URL -> fragment.navigate<BrowserFragment>(url); ContentType.URL -> fragment.navigate<BrowserFragment>(url);
else -> {}; else -> {};
} }

View File

@ -125,6 +125,7 @@ abstract class ContentFeedView<TFragment> : FeedView<TFragment, IPlatformContent
protected open fun onContentClicked(content: IPlatformContent, time: Long) { protected open fun onContentClicked(content: IPlatformContent, time: Long) {
if(content is IPlatformVideo) { if(content is IPlatformVideo) {
StatePlayer.instance.clearQueue();
if (Settings.instance.playback.shouldResumePreview(time)) if (Settings.instance.playback.shouldResumePreview(time))
fragment.navigate<VideoDetailFragment>(content.withTimestamp(time)).maximizeVideoDetail(); fragment.navigate<VideoDetailFragment>(content.withTimestamp(time)).maximizeVideoDetail();
else else
@ -137,7 +138,10 @@ abstract class ContentFeedView<TFragment> : FeedView<TFragment, IPlatformContent
} }
protected open fun onContentUrlClicked(url: String, contentType: ContentType) { protected open fun onContentUrlClicked(url: String, contentType: ContentType) {
when(contentType) { when(contentType) {
ContentType.MEDIA -> fragment.navigate<VideoDetailFragment>(url).maximizeVideoDetail(); ContentType.MEDIA -> {
StatePlayer.instance.clearQueue();
fragment.navigate<VideoDetailFragment>(url).maximizeVideoDetail();
};
ContentType.PLAYLIST -> fragment.navigate<PlaylistFragment>(url); ContentType.PLAYLIST -> fragment.navigate<PlaylistFragment>(url);
ContentType.URL -> fragment.navigate<BrowserFragment>(url); ContentType.URL -> fragment.navigate<BrowserFragment>(url);
else -> {}; else -> {};

View File

@ -13,6 +13,7 @@ import com.futo.platformplayer.downloads.VideoDownload
import com.futo.platformplayer.downloads.VideoLocal import com.futo.platformplayer.downloads.VideoLocal
import com.futo.platformplayer.logging.Logger import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.states.StateDownloads import com.futo.platformplayer.states.StateDownloads
import com.futo.platformplayer.states.StatePlayer
import com.futo.platformplayer.views.AnyInsertedAdapterView import com.futo.platformplayer.views.AnyInsertedAdapterView
import com.futo.platformplayer.views.AnyInsertedAdapterView.Companion.asAnyWithTop import com.futo.platformplayer.views.AnyInsertedAdapterView.Companion.asAnyWithTop
import com.futo.platformplayer.views.others.ProgressBar import com.futo.platformplayer.views.others.ProgressBar
@ -123,6 +124,7 @@ class DownloadsFragment : MainFragment() {
_listDownloaded = findViewById<RecyclerView>(R.id.list_downloaded) _listDownloaded = findViewById<RecyclerView>(R.id.list_downloaded)
.asAnyWithTop(findViewById(R.id.downloads_top)) { .asAnyWithTop(findViewById(R.id.downloads_top)) {
it.onClick.subscribe { it.onClick.subscribe {
StatePlayer.instance.clearQueue();
_frag.navigate<VideoDetailFragment>(it).maximizeVideoDetail(); _frag.navigate<VideoDetailFragment>(it).maximizeVideoDetail();
} }
}; };

View File

@ -12,6 +12,7 @@ import androidx.core.widget.addTextChangedListener
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.futo.platformplayer.* import com.futo.platformplayer.*
import com.futo.platformplayer.states.StatePlayer
import com.futo.platformplayer.states.StatePlaylists import com.futo.platformplayer.states.StatePlaylists
import com.futo.platformplayer.views.others.TagsView import com.futo.platformplayer.views.others.TagsView
import com.futo.platformplayer.views.adapters.HistoryListAdapter import com.futo.platformplayer.views.adapters.HistoryListAdapter
@ -44,6 +45,7 @@ class HistoryFragment : MainFragment() {
adapter.onClick.subscribe { v -> adapter.onClick.subscribe { v ->
val diff = v.video.duration - v.position; val diff = v.video.duration - v.position;
val vid: Any = if (diff > 5) { v.video.withTimestamp(v.position) } else { v.video }; val vid: Any = if (diff > 5) { v.video.withTimestamp(v.position) } else { v.video };
StatePlayer.instance.clearQueue();
navigate<VideoDetailFragment>(vid).maximizeVideoDetail(); navigate<VideoDetailFragment>(vid).maximizeVideoDetail();
editSearch.clearFocus(); editSearch.clearFocus();
inputMethodManager.hideSoftInputFromWindow(editSearch.windowToken, 0); inputMethodManager.hideSoftInputFromWindow(editSearch.windowToken, 0);

View File

@ -301,6 +301,7 @@ class VideoDetailView : ConstraintLayout {
_player.attachPlayer(); _player.attachPlayer();
_container_content_liveChat.onRaidNow.subscribe { _container_content_liveChat.onRaidNow.subscribe {
StatePlayer.instance.clearQueue();
fragment.navigate<VideoDetailFragment>(it.targetUrl); fragment.navigate<VideoDetailFragment>(it.targetUrl);
}; };

View File

@ -136,7 +136,7 @@ class StatePlayer {
fun setQueueType(queueType : String) { fun setQueueType(queueType : String) {
when(queueType) { when(queueType) {
TYPE_QUEUE -> { TYPE_QUEUE -> {
_queueRemoveOnFinish = true; _queueRemoveOnFinish = false;
} }
TYPE_WATCHLATER -> { TYPE_WATCHLATER -> {
_queueRemoveOnFinish = true; _queueRemoveOnFinish = true;