Skip to content

Commit

Permalink
Move code to function
Browse files Browse the repository at this point in the history
  • Loading branch information
Natanel-Shitrit committed Aug 12, 2023
1 parent f33454b commit adaad0f
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions app/phone/src/main/java/dev/jdtech/jellyfin/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,7 @@ class PlayerActivity : BasePlayerActivity() {
speedButton.isEnabled = true
speedButton.imageAlpha = 255

if (appPreferences.showChapterMarkers) {
val playerControlView = findViewById<PlayerControlView>(R.id.exo_controller)
val chapters: LongArray = when (viewModel.player) {
is MPVPlayer -> {
val player = (viewModel.player as MPVPlayer)
LongArray(player.getNumberOfChapters()) { index -> player.getChapterTime(index).toLong() * 1000 }
}
else -> LongArray(0)
}

playerControlView.setExtraAdGroupMarkers(
chapters,
BooleanArray(chapters.size) { false },
)
}
loadChapters()
}
}
}
Expand Down Expand Up @@ -277,4 +263,22 @@ class PlayerActivity : BasePlayerActivity() {
viewModel.initializePlayer(args.items)
hideSystemUI()
}

private fun loadChapters() {
if (appPreferences.showChapterMarkers) {
val playerControlView = findViewById<PlayerControlView>(R.id.exo_controller)
val chapters: LongArray = when (viewModel.player) {
is MPVPlayer -> {
val player = (viewModel.player as MPVPlayer)
LongArray(player.getNumberOfChapters()) { index -> player.getChapterTime(index).toLong() * 1000 }
}
else -> LongArray(0)
}

playerControlView.setExtraAdGroupMarkers(
chapters,
BooleanArray(chapters.size) { false },
)
}
}
}

0 comments on commit adaad0f

Please sign in to comment.