mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +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:retrofit:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-jackson: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.fasterxml.jackson.core:jackson-annotations:2.13.1'
|
||||||
|
|
||||||
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1.LTS'
|
implementation 'com.arthenica:ffmpeg-kit-min:4.5.1.LTS'
|
||||||
|
@ -234,9 +234,11 @@ class PlayerFragment : Fragment() {
|
|||||||
} catch(e: IOException) {
|
} catch(e: IOException) {
|
||||||
println(e)
|
println(e)
|
||||||
Log.e(TAG, "IOException, you might not have internet connection")
|
Log.e(TAG, "IOException, you might not have internet connection")
|
||||||
|
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
} catch (e: HttpException) {
|
} catch (e: HttpException) {
|
||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
|
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
var videosNameArray: Array<CharSequence> = arrayOf()
|
var videosNameArray: Array<CharSequence> = arrayOf()
|
||||||
@ -267,9 +269,11 @@ class PlayerFragment : Fragment() {
|
|||||||
val defres = sharedPreferences.getString("default_res", "")!!
|
val defres = sharedPreferences.getString("default_res", "")!!
|
||||||
when {
|
when {
|
||||||
defres!="" -> {
|
defres!="" -> {
|
||||||
|
var foundRes = false
|
||||||
run lit@ {
|
run lit@ {
|
||||||
response.videoStreams!!.forEachIndexed { index, pipedStream ->
|
response.videoStreams!!.forEachIndexed { index, pipedStream ->
|
||||||
if (pipedStream.quality!!.contains(defres)){
|
if (pipedStream.quality!!.contains(defres)){
|
||||||
|
foundRes = true
|
||||||
val dataSourceFactory: DataSource.Factory =
|
val dataSourceFactory: DataSource.Factory =
|
||||||
DefaultHttpDataSource.Factory()
|
DefaultHttpDataSource.Factory()
|
||||||
val videoItem: MediaItem = MediaItem.Builder()
|
val videoItem: MediaItem = MediaItem.Builder()
|
||||||
@ -288,6 +292,12 @@ class PlayerFragment : Fragment() {
|
|||||||
exoPlayer.setMediaSource(mergeSource)
|
exoPlayer.setMediaSource(mergeSource)
|
||||||
view.findViewById<TextView>(R.id.quality_text).text=videosNameArray[index+1]
|
view.findViewById<TextView>(R.id.quality_text).text=videosNameArray[index+1]
|
||||||
return@lit
|
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>
|
<item>D</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="defres">
|
<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>1080p</item>
|
||||||
<item>720p</item>
|
<item>720p</item>
|
||||||
<item>480p</item>
|
<item>480p</item>
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
app:title="@string/defres"
|
app:title="@string/defres"
|
||||||
app:key="default_res"
|
app:key="default_res"
|
||||||
app:entries="@array/defres"
|
app:entries="@array/defres"
|
||||||
app:entryValues="@array/defres"
|
app:entryValues="@array/defresValue"
|
||||||
app:defaultValue=""
|
app:defaultValue=""
|
||||||
android:icon="@drawable/ic_hd"
|
android:icon="@drawable/ic_hd"
|
||||||
app:useSimpleSummaryProvider="true"
|
app:useSimpleSummaryProvider="true"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user