From b652597924aa053c11493b98713babc66b74d052 Mon Sep 17 00:00:00 2001 From: Kelvin K Date: Fri, 28 Mar 2025 21:40:17 +0100 Subject: [PATCH] chapters ui on text press --- .../mainactivity/main/VideoDetailView.kt | 30 +++++++++++++------ .../views/video/FutoVideoPlayer.kt | 8 +++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt index db5c6060..47ac35d2 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt @@ -404,6 +404,10 @@ class VideoDetailView : ConstraintLayout { _monetization = findViewById(R.id.monetization); _player.attachPlayer(); + _player.onChapterClicked.subscribe { + showChaptersUI(); + }; + _buttonSubscribe.onSubscribed.subscribe { _slideUpOverlay = UISlideOverlays.showSubscriptionOptionsOverlay(it, _overlayContainer); @@ -863,6 +867,22 @@ class VideoDetailView : ConstraintLayout { _cast.stopAllGestures(); } + fun showChaptersUI(){ + video?.let { + try { + _chapters?.let { + if(it.size == 0) + return@let; + _container_content_chapters.setChapters(_chapters); + switchContentView(_container_content_chapters); + } + } + catch(ex: Throwable) { + + } + } + } + fun updateMoreButtons() { val isLimitedVersion = video?.url != null && StatePlatform.instance.getContentClientOrNull(video!!.url)?.let { if (it is JSClient) @@ -879,15 +899,7 @@ class VideoDetailView : ConstraintLayout { _chapters?.let { if(it != null && it.size > 0) RoundButton(context, R.drawable.ic_list, "Chapters", TAG_CHAPTERS) { - video?.let { - try { - _container_content_chapters.setChapters(_chapters); - switchContentView(_container_content_chapters); - } - catch(ex: Throwable) { - - } - } + showChaptersUI(); } else null }, diff --git a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt index ec0345fb..1daa7808 100644 --- a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt +++ b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt @@ -145,6 +145,8 @@ class FutoVideoPlayer : FutoVideoPlayerBase { val onVideoClicked = Event0(); val onTimeBarChanged = Event2(); + val onChapterClicked = Event1(); + @OptIn(UnstableApi::class) constructor(context: Context, attrs: AttributeSet? = null) : super(PLAYER_STATE_NAME, context, attrs) { LayoutInflater.from(context).inflate(R.layout.video_view, this, true); @@ -185,6 +187,12 @@ class FutoVideoPlayer : FutoVideoPlayerBase { _control_duration_fullscreen = _videoControls_fullscreen.findViewById(R.id.text_duration); _control_pause_fullscreen = _videoControls_fullscreen.findViewById(R.id.button_pause); + _control_chapter.setOnClickListener { + _currentChapter?.let { + onChapterClicked.emit(it); + } + } + val castVisibility = if (Settings.instance.casting.enabled) View.VISIBLE else View.GONE _control_cast.visibility = castVisibility _control_cast_fullscreen.visibility = castVisibility