mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
default resolution
This commit is contained in:
parent
adad574c18
commit
aaa8bda9ff
@ -25,13 +25,13 @@
|
|||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"filterType": "ABI",
|
"filterType": "ABI",
|
||||||
"value": "arm64-v8a"
|
"value": "armeabi-v7a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 5,
|
"versionCode": 5,
|
||||||
"versionName": "0.2.3",
|
"versionName": "0.2.3",
|
||||||
"outputFile": "app-arm64-v8a-release.apk"
|
"outputFile": "app-armeabi-v7a-release.apk"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "ONE_OF_MANY",
|
"type": "ONE_OF_MANY",
|
||||||
@ -51,13 +51,13 @@
|
|||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"filterType": "ABI",
|
"filterType": "ABI",
|
||||||
"value": "armeabi-v7a"
|
"value": "arm64-v8a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 5,
|
"versionCode": 5,
|
||||||
"versionName": "0.2.3",
|
"versionName": "0.2.3",
|
||||||
"outputFile": "app-armeabi-v7a-release.apk"
|
"outputFile": "app-arm64-v8a-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"elementType": "File"
|
"elementType": "File"
|
||||||
|
@ -263,13 +263,44 @@ class PlayerFragment : Fragment() {
|
|||||||
//exoPlayerView.controllerShowTimeoutMs = 1500
|
//exoPlayerView.controllerShowTimeoutMs = 1500
|
||||||
exoPlayerView.controllerHideOnTouch = true
|
exoPlayerView.controllerHideOnTouch = true
|
||||||
exoPlayerView.player = exoPlayer
|
exoPlayerView.player = exoPlayer
|
||||||
if (response.hls != null) {
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
val defres = sharedPreferences.getString("default_res", "")!!
|
||||||
|
when {
|
||||||
|
defres!="" -> {
|
||||||
|
run lit@ {
|
||||||
|
response.videoStreams!!.forEachIndexed { index, pipedStream ->
|
||||||
|
if (pipedStream.quality!!.contains(defres)){
|
||||||
|
val dataSourceFactory: DataSource.Factory =
|
||||||
|
DefaultHttpDataSource.Factory()
|
||||||
|
val videoItem: MediaItem = MediaItem.Builder()
|
||||||
|
.setUri(response.videoStreams[index].url)
|
||||||
|
.setSubtitleConfigurations(subtitle)
|
||||||
|
.build()
|
||||||
|
val videoSource: MediaSource = DefaultMediaSourceFactory(dataSourceFactory)
|
||||||
|
.createMediaSource(videoItem)
|
||||||
|
var audioSource: MediaSource = DefaultMediaSourceFactory(dataSourceFactory)
|
||||||
|
.createMediaSource(fromUri(response.audioStreams!![0].url!!))
|
||||||
|
if (response.videoStreams[index].quality=="720p" || response.videoStreams[index].quality=="1080p" || response.videoStreams[index].quality=="480p" ){
|
||||||
|
audioSource = ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||||
|
.createMediaSource(fromUri(response.audioStreams!![getMostBitRate(response.audioStreams)].url!!))
|
||||||
|
}
|
||||||
|
val mergeSource: MediaSource = MergingMediaSource(videoSource,audioSource)
|
||||||
|
exoPlayer.setMediaSource(mergeSource)
|
||||||
|
view.findViewById<TextView>(R.id.quality_text).text=videosNameArray[index+1]
|
||||||
|
return@lit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
response.hls != null -> {
|
||||||
val mediaItem: MediaItem = MediaItem.Builder()
|
val mediaItem: MediaItem = MediaItem.Builder()
|
||||||
.setUri(response.hls)
|
.setUri(response.hls)
|
||||||
.setSubtitleConfigurations(subtitle)
|
.setSubtitleConfigurations(subtitle)
|
||||||
.build()
|
.build()
|
||||||
exoPlayer.setMediaItem(mediaItem)
|
exoPlayer.setMediaItem(mediaItem)
|
||||||
}else{
|
}
|
||||||
|
else -> {
|
||||||
val dataSourceFactory: DataSource.Factory =
|
val dataSourceFactory: DataSource.Factory =
|
||||||
DefaultHttpDataSource.Factory()
|
DefaultHttpDataSource.Factory()
|
||||||
val videoItem: MediaItem = MediaItem.Builder()
|
val videoItem: MediaItem = MediaItem.Builder()
|
||||||
@ -286,6 +317,8 @@ class PlayerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
val mergeSource: MediaSource = MergingMediaSource(videoSource,audioSource)
|
val mergeSource: MediaSource = MergingMediaSource(videoSource,audioSource)
|
||||||
exoPlayer.setMediaSource(mergeSource)
|
exoPlayer.setMediaSource(mergeSource)
|
||||||
|
view.findViewById<TextView>(R.id.quality_text).text=videosNameArray[1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///exoPlayer.getMediaItemAt(5)
|
///exoPlayer.getMediaItemAt(5)
|
||||||
|
10
app/src/main/res/drawable/ic_hd.xml
Normal file
10
app/src/main/res/drawable/ic_hd.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM11,15L9.5,15v-2h-2v2L6,15L6,9h1.5v2.5h2L9.5,9L11,9v6zM13,9h4c0.55,0 1,0.45 1,1v4c0,0.55 -0.45,1 -1,1h-4L13,9zM14.5,13.5h2v-3h-2v3z"/>
|
||||||
|
</vector>
|
@ -416,5 +416,12 @@
|
|||||||
<item>L</item>
|
<item>L</item>
|
||||||
<item>D</item>
|
<item>D</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="defres">
|
||||||
|
<item>1080p</item>
|
||||||
|
<item>720p</item>
|
||||||
|
<item>480p</item>
|
||||||
|
<item>360p</item>
|
||||||
|
<item>240p</item>
|
||||||
|
<item>144p</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
@ -35,4 +35,5 @@
|
|||||||
<string name="unknown_error">Network error!</string>
|
<string name="unknown_error">Network error!</string>
|
||||||
<string name="empty">Username and Password can\'t be empty!</string>
|
<string name="empty">Username and Password can\'t be empty!</string>
|
||||||
<string name="notgmail">This is not your gmail account!</string>
|
<string name="notgmail">This is not your gmail account!</string>
|
||||||
|
<string name="defres">Default Video Resolution</string>
|
||||||
</resources>
|
</resources>
|
@ -50,6 +50,14 @@
|
|||||||
app:defaultValue="A"
|
app:defaultValue="A"
|
||||||
android:icon="@drawable/ic_theme"
|
android:icon="@drawable/ic_theme"
|
||||||
/>
|
/>
|
||||||
|
<ListPreference
|
||||||
|
app:title="@string/defres"
|
||||||
|
app:key="default_res"
|
||||||
|
app:entries="@array/defres"
|
||||||
|
app:entryValues="@array/defres"
|
||||||
|
app:defaultValue=""
|
||||||
|
android:icon="@drawable/ic_hd"
|
||||||
|
app:useSimpleSummaryProvider="true"
|
||||||
|
/>
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user