mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
fix: wrong chapter name shown if following video has only SB highlight
This commit is contained in:
parent
aa2fd8384d
commit
3a372f4854
@ -434,6 +434,10 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
setFullscreen()
|
||||
}
|
||||
|
||||
chaptersViewModel.chaptersLiveData.observe(viewLifecycleOwner) {
|
||||
binding.player.setCurrentChapterName()
|
||||
}
|
||||
|
||||
playVideo()
|
||||
|
||||
showBottomBar()
|
||||
@ -1007,8 +1011,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
// show the player notification
|
||||
initializePlayerNotification()
|
||||
|
||||
binding.player.setCurrentChapterName()
|
||||
|
||||
fetchSponsorBlockSegments()
|
||||
|
||||
if (streams.category == Streams.categoryMusic) {
|
||||
@ -1103,10 +1105,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
playerBinding.exoTitle.text = streams.title
|
||||
|
||||
// init the chapters recyclerview
|
||||
chaptersViewModel.chaptersLiveData.value = streams.chapters
|
||||
chaptersViewModel.chaptersLiveData.observe(viewLifecycleOwner) {
|
||||
binding.player.setCurrentChapterName()
|
||||
}
|
||||
chaptersViewModel.chaptersLiveData.postValue(streams.chapters)
|
||||
|
||||
if (PlayerHelper.relatedStreamsEnabled) {
|
||||
val relatedLayoutManager = binding.relatedRecView.layoutManager as LinearLayoutManager
|
||||
|
@ -10,6 +10,7 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.format.DateUtils
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
@ -259,6 +260,7 @@ abstract class CustomExoPlayerView(
|
||||
val player = player ?: return
|
||||
val chapters = chaptersViewModel.chapters
|
||||
|
||||
Log.e("cha", chapters.isEmpty().toString())
|
||||
binding.chapterName.isInvisible = chapters.isEmpty()
|
||||
|
||||
// the following logic to set the chapter title can be skipped if no chapters are available
|
||||
@ -272,7 +274,8 @@ abstract class CustomExoPlayerView(
|
||||
|
||||
val currentIndex = PlayerHelper.getCurrentChapterIndex(player.currentPosition, chapters)
|
||||
val newChapterName = currentIndex?.let { chapters[it].title.trim() }.orEmpty()
|
||||
chaptersViewModel.currentChapterIndex.updateIfChanged(currentIndex ?: return)
|
||||
|
||||
chaptersViewModel.currentChapterIndex.updateIfChanged(currentIndex ?: -1)
|
||||
|
||||
// change the chapter name textView text to the chapterName
|
||||
if (newChapterName != binding.chapterName.text) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user