mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
code cleanupü
This commit is contained in:
parent
e7d60a5fe9
commit
ca86cb1768
@ -466,12 +466,8 @@ class PlayerFragment : BaseFragment() {
|
||||
videosNameArray[which] == getString(R.string.hls) ||
|
||||
videosNameArray[which] == "LBRY HLS"
|
||||
) {
|
||||
// no need to merge sources if using hls
|
||||
val mediaItem: MediaItem = MediaItem.Builder()
|
||||
.setUri(videosUrlArray[which])
|
||||
.setSubtitleConfigurations(subtitle)
|
||||
.build()
|
||||
exoPlayer.setMediaItem(mediaItem)
|
||||
// set the progressive media source
|
||||
setProgressiveMediaSource(videosUrlArray[which])
|
||||
} else {
|
||||
val videoUri = videosUrlArray[which]
|
||||
val audioUrl =
|
||||
@ -1194,7 +1190,9 @@ class PlayerFragment : BaseFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
// get the name of the currently played chapter
|
||||
/**
|
||||
* Get the name of the currently played chapter
|
||||
*/
|
||||
private fun getCurrentChapterIndex(): Int {
|
||||
val currentPosition = exoPlayer.currentPosition
|
||||
var chapterIndex = 0
|
||||
@ -1230,6 +1228,14 @@ class PlayerFragment : BaseFragment() {
|
||||
exoPlayer.setMediaSource(mergeSource)
|
||||
}
|
||||
|
||||
private fun setProgressiveMediaSource(uri: Uri) {
|
||||
val mediaItem: MediaItem = MediaItem.Builder()
|
||||
.setUri(uri)
|
||||
.setSubtitleConfigurations(subtitle)
|
||||
.build()
|
||||
exoPlayer.setMediaItem(mediaItem)
|
||||
}
|
||||
|
||||
private fun getAvailableResolutions(): Pair<Array<String>, Array<Uri>> {
|
||||
if (!this::streams.isInitialized) return Pair(arrayOf(), arrayOf())
|
||||
|
||||
@ -1311,11 +1317,7 @@ class PlayerFragment : BaseFragment() {
|
||||
|
||||
// if default resolution isn't set or available, use hls if available
|
||||
if (streams.hls != null) {
|
||||
val mediaItem: MediaItem = MediaItem.Builder()
|
||||
.setUri(streams.hls)
|
||||
.setSubtitleConfigurations(subtitle)
|
||||
.build()
|
||||
exoPlayer.setMediaItem(mediaItem)
|
||||
setProgressiveMediaSource(Uri.parse(streams.hls))
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user