mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
default quality
This commit is contained in:
parent
1e3e04031b
commit
5c84e204d2
@ -71,6 +71,7 @@ dependencies {
|
||||
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-jackson:2.9.0'
|
||||
//do not update jackson annotations! it does not supports <api26
|
||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.1'
|
||||
|
||||
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1.LTS'
|
||||
|
@ -234,9 +234,11 @@ class PlayerFragment : Fragment() {
|
||||
} catch(e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}
|
||||
var videosNameArray: Array<CharSequence> = arrayOf()
|
||||
@ -267,9 +269,11 @@ class PlayerFragment : Fragment() {
|
||||
val defres = sharedPreferences.getString("default_res", "")!!
|
||||
when {
|
||||
defres!="" -> {
|
||||
var foundRes = false
|
||||
run lit@ {
|
||||
response.videoStreams!!.forEachIndexed { index, pipedStream ->
|
||||
if (pipedStream.quality!!.contains(defres)){
|
||||
foundRes = true
|
||||
val dataSourceFactory: DataSource.Factory =
|
||||
DefaultHttpDataSource.Factory()
|
||||
val videoItem: MediaItem = MediaItem.Builder()
|
||||
@ -288,6 +292,12 @@ class PlayerFragment : Fragment() {
|
||||
exoPlayer.setMediaSource(mergeSource)
|
||||
view.findViewById<TextView>(R.id.quality_text).text=videosNameArray[index+1]
|
||||
return@lit
|
||||
}else if (index+1 == response.videoStreams.size){
|
||||
val mediaItem: MediaItem = MediaItem.Builder()
|
||||
.setUri(response.hls)
|
||||
.setSubtitleConfigurations(subtitle)
|
||||
.build()
|
||||
exoPlayer.setMediaItem(mediaItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -417,6 +417,16 @@
|
||||
<item>D</item>
|
||||
</string-array>
|
||||
<string-array name="defres">
|
||||
<item>HLS</item>
|
||||
<item>1080p</item>
|
||||
<item>720p</item>
|
||||
<item>480p</item>
|
||||
<item>360p</item>
|
||||
<item>240p</item>
|
||||
<item>144p</item>
|
||||
</string-array>
|
||||
<string-array name="defresValue">
|
||||
<item></item>
|
||||
<item>1080p</item>
|
||||
<item>720p</item>
|
||||
<item>480p</item>
|
||||
|
@ -54,7 +54,7 @@
|
||||
app:title="@string/defres"
|
||||
app:key="default_res"
|
||||
app:entries="@array/defres"
|
||||
app:entryValues="@array/defres"
|
||||
app:entryValues="@array/defresValue"
|
||||
app:defaultValue=""
|
||||
android:icon="@drawable/ic_hd"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
|
Loading…
x
Reference in New Issue
Block a user