rename hls to auto

This commit is contained in:
Bnyro 2022-07-03 13:28:24 +02:00
parent 5c3fda3d1f
commit b7d9d510f6
5 changed files with 28 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isVisible import androidx.core.view.isVisible
@ -75,6 +76,7 @@ import com.google.android.exoplayer2.upstream.DataSource
import com.google.android.exoplayer2.upstream.DefaultDataSource import com.google.android.exoplayer2.upstream.DefaultDataSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.google.android.exoplayer2.util.RepeatModeUtil import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.exoplayer2.video.VideoSize
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
@ -169,6 +171,7 @@ class PlayerFragment : Fragment() {
mainActivity.binding.container.visibility = View.VISIBLE mainActivity.binding.container.visibility = View.VISIBLE
exoPlayerView = binding.player exoPlayerView = binding.player
binding.mainContainer.visibility = View.GONE
binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener { binding.playerMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionStarted( override fun onTransitionStarted(
@ -671,6 +674,24 @@ class PlayerFragment : Fragment() {
} }
} }
override fun onVideoSizeChanged(
videoSize: VideoSize
) {
// Set new width/height of view
// height or width must be cast to float as int/int will give 0
val currentWidth = binding.mainContainer.height
// Redraw myView
(binding.mainContainer.layoutParams as ConstraintLayout.LayoutParams).apply {
matchConstraintPercentHeight = (
videoSize.height / videoSize.width * currentWidth
).toFloat()
}
binding.mainContainer.requestLayout()
// FIXME and make me work :/
}
@Deprecated(message = "Deprecated", level = DeprecationLevel.HIDDEN) @Deprecated(message = "Deprecated", level = DeprecationLevel.HIDDEN)
override fun onPlayerStateChanged( override fun onPlayerStateChanged(
playWhenReady: Boolean, playWhenReady: Boolean,
@ -835,7 +856,7 @@ class PlayerFragment : Fragment() {
// append hls to list if available // append hls to list if available
if (response.hls != null) { if (response.hls != null) {
videosNameArray += "HLS" videosNameArray += getString(R.string.hls)
videosUrlArray += response.hls.toUri() videosUrlArray += response.hls.toUri()
} }
@ -916,7 +937,7 @@ class PlayerFragment : Fragment() {
) { _, which -> ) { _, which ->
whichQuality = which whichQuality = which
if ( if (
videosNameArray[which] == "HLS" || videosNameArray[which] == getString(R.string.hls) ||
videosNameArray[which] == "LBRY HLS" videosNameArray[which] == "LBRY HLS"
) { ) {
// no need to merge sources if using hls // no need to merge sources if using hls

View File

@ -110,7 +110,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:padding="@dimen/exo_icon_padding" android:padding="@dimen/exo_icon_padding"
android:text="HLS" android:text="@string/hls"
android:textColor="#FFFFFF" /> android:textColor="#FFFFFF" />
<ImageView <ImageView

View File

@ -347,15 +347,14 @@
android:layout_height="0dp" android:layout_height="0dp"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.35" app:layout_constraintHeight_percent="0.3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<com.github.libretube.views.CustomExoPlayerView <com.github.libretube.views.CustomExoPlayerView
android:id="@+id/player" android:id="@+id/player"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent"
android:background="#000000" android:background="#000000"
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="@id/main_container" app:layout_constraintBottom_toBottomOf="@id/main_container"

View File

@ -572,7 +572,7 @@
</string-array> </string-array>
<string-array name="defres"> <string-array name="defres">
<item>HLS</item> <item>@string/hls</item>
<item>1080p</item> <item>1080p</item>
<item>720p</item> <item>720p</item>
<item>480p</item> <item>480p</item>

View File

@ -213,4 +213,5 @@
<string name="auth_instance">Authentication instance</string> <string name="auth_instance">Authentication instance</string>
<string name="auth_instance_summary">Use a different instance for authenticated calls.</string> <string name="auth_instance_summary">Use a different instance for authenticated calls.</string>
<string name="auth_instances">Choose an auth instance</string> <string name="auth_instances">Choose an auth instance</string>
<string name="hls">Auto</string>
</resources> </resources>