mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
commit
8a7d8ce32e
@ -153,12 +153,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* don't remove this line
|
|
||||||
* this prevents reselected items at the bottomNav to be duplicated in the backstack
|
|
||||||
*/
|
|
||||||
binding.bottomNav.setOnItemReselectedListener {}
|
|
||||||
|
|
||||||
binding.toolbar.title = ThemeHelper.getStyledAppName(this)
|
binding.toolbar.title = ThemeHelper.getStyledAppName(this)
|
||||||
|
|
||||||
binding.toolbar.setNavigationOnClickListener {
|
binding.toolbar.setNavigationOnClickListener {
|
||||||
|
@ -1033,22 +1033,29 @@ class PlayerFragment : Fragment() {
|
|||||||
// call the function again in 100ms
|
// call the function again in 100ms
|
||||||
exoPlayerView.postDelayed(this::setCurrentChapterName, 100)
|
exoPlayerView.postDelayed(this::setCurrentChapterName, 100)
|
||||||
|
|
||||||
val currentPosition = exoPlayer.currentPosition
|
var chapterName = getCurrentChapterName()
|
||||||
var chapterName: String? = null
|
|
||||||
val reversedChapters = chapters.toMutableList()
|
|
||||||
|
|
||||||
// reverse the chapters to start at the end
|
|
||||||
reversedChapters.reverse()
|
|
||||||
reversedChapters.forEach {
|
|
||||||
// check whether the chapter start is greater than the current player position
|
|
||||||
if (it.start!! * 1000 >= currentPosition) chapterName = it.title
|
|
||||||
}
|
|
||||||
// change the chapter name textView text to the chapterName
|
// change the chapter name textView text to the chapterName
|
||||||
if (chapterName != null && chapterName != playerBinding.chapterName.text) {
|
if (chapterName != null && chapterName != playerBinding.chapterName.text) {
|
||||||
playerBinding.chapterName.text = chapterName
|
playerBinding.chapterName.text = chapterName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the name of the currently played chapter
|
||||||
|
private fun getCurrentChapterName(): String? {
|
||||||
|
val currentPosition = exoPlayer.currentPosition
|
||||||
|
var chapterName: String? = null
|
||||||
|
|
||||||
|
chapters.forEach {
|
||||||
|
// check whether the chapter start is greater than the current player position
|
||||||
|
if (currentPosition >= it.start!! * 1000) {
|
||||||
|
// save chapter title if found
|
||||||
|
chapterName = it.title
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chapterName
|
||||||
|
}
|
||||||
|
|
||||||
private fun setMediaSource(
|
private fun setMediaSource(
|
||||||
subtitle: MutableList<SubtitleConfiguration>,
|
subtitle: MutableList<SubtitleConfiguration>,
|
||||||
videoUri: Uri,
|
videoUri: Uri,
|
||||||
|
Loading…
Reference in New Issue
Block a user