mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +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] == getString(R.string.hls) ||
|
||||||
videosNameArray[which] == "LBRY HLS"
|
videosNameArray[which] == "LBRY HLS"
|
||||||
) {
|
) {
|
||||||
// no need to merge sources if using hls
|
// set the progressive media source
|
||||||
val mediaItem: MediaItem = MediaItem.Builder()
|
setProgressiveMediaSource(videosUrlArray[which])
|
||||||
.setUri(videosUrlArray[which])
|
|
||||||
.setSubtitleConfigurations(subtitle)
|
|
||||||
.build()
|
|
||||||
exoPlayer.setMediaItem(mediaItem)
|
|
||||||
} else {
|
} else {
|
||||||
val videoUri = videosUrlArray[which]
|
val videoUri = videosUrlArray[which]
|
||||||
val audioUrl =
|
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 {
|
private fun getCurrentChapterIndex(): Int {
|
||||||
val currentPosition = exoPlayer.currentPosition
|
val currentPosition = exoPlayer.currentPosition
|
||||||
var chapterIndex = 0
|
var chapterIndex = 0
|
||||||
@ -1230,6 +1228,14 @@ class PlayerFragment : BaseFragment() {
|
|||||||
exoPlayer.setMediaSource(mergeSource)
|
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>> {
|
private fun getAvailableResolutions(): Pair<Array<String>, Array<Uri>> {
|
||||||
if (!this::streams.isInitialized) return Pair(arrayOf(), arrayOf())
|
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 default resolution isn't set or available, use hls if available
|
||||||
if (streams.hls != null) {
|
if (streams.hls != null) {
|
||||||
val mediaItem: MediaItem = MediaItem.Builder()
|
setProgressiveMediaSource(Uri.parse(streams.hls))
|
||||||
.setUri(streams.hls)
|
|
||||||
.setSubtitleConfigurations(subtitle)
|
|
||||||
.build()
|
|
||||||
exoPlayer.setMediaItem(mediaItem)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user