mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 15:30:31 +05:30
Merge pull request #2552 from Bnyro/master
Replace the autoplay option with a switch
This commit is contained in:
commit
97e24999f8
@ -107,15 +107,15 @@ import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSource
|
||||
import com.google.android.exoplayer2.util.MimeTypes
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.chromium.net.CronetEngine
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
|
||||
class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
|
||||
@ -314,6 +314,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
.commit()
|
||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||
}
|
||||
playerBinding.autoPlay.visibility = View.VISIBLE
|
||||
|
||||
binding.playImageView.setOnClickListener {
|
||||
if (!exoPlayer.isPlaying) {
|
||||
@ -1162,8 +1163,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
|
||||
for (vid in videoStreams) {
|
||||
if (resolutions.any {
|
||||
it.resolution == vid.quality.qualityToInt()
|
||||
} || vid.url == null
|
||||
it.resolution == vid.quality.qualityToInt()
|
||||
} || vid.url == null
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.github.libretube.ui.interfaces
|
||||
|
||||
interface PlayerOptions {
|
||||
fun onAutoplayClicked()
|
||||
|
||||
fun onPlaybackSpeedClicked()
|
||||
|
||||
|
@ -127,6 +127,12 @@ internal class CustomExoPlayerView(
|
||||
isPlayerLocked = !isPlayerLocked
|
||||
}
|
||||
|
||||
binding.autoPlay.isChecked = autoplayEnabled
|
||||
|
||||
binding.autoPlay.setOnCheckedChangeListener { _, isChecked ->
|
||||
autoplayEnabled = isChecked
|
||||
}
|
||||
|
||||
resizeMode = when (resizeModePref) {
|
||||
"fill" -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
"zoom" -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
@ -213,19 +219,6 @@ internal class CustomExoPlayerView(
|
||||
private fun initializeAdvancedOptions(context: Context) {
|
||||
binding.toggleOptions.setOnClickListener {
|
||||
val items = mutableListOf(
|
||||
BottomSheetItem(
|
||||
context.getString(R.string.player_autoplay),
|
||||
R.drawable.ic_play,
|
||||
{
|
||||
if (autoplayEnabled) {
|
||||
context.getString(R.string.enabled)
|
||||
} else {
|
||||
context.getString(R.string.disabled)
|
||||
}
|
||||
}
|
||||
) {
|
||||
onAutoplayClicked()
|
||||
},
|
||||
BottomSheetItem(
|
||||
context.getString(R.string.repeat_mode),
|
||||
R.drawable.ic_repeat,
|
||||
@ -446,23 +439,6 @@ internal class CustomExoPlayerView(
|
||||
gestureViewBinding.volumeTextView.text = "${bar.progress.normalize(0, bar.max, 0, 100)}"
|
||||
}
|
||||
|
||||
override fun onAutoplayClicked() {
|
||||
// autoplay options dialog
|
||||
BaseBottomSheet()
|
||||
.setSimpleItems(
|
||||
listOf(
|
||||
context.getString(R.string.enabled),
|
||||
context.getString(R.string.disabled)
|
||||
)
|
||||
) { index ->
|
||||
when (index) {
|
||||
0 -> autoplayEnabled = true
|
||||
1 -> autoplayEnabled = false
|
||||
}
|
||||
}
|
||||
.show(supportFragmentManager)
|
||||
}
|
||||
|
||||
override fun onPlaybackSpeedClicked() {
|
||||
player?.let { PlaybackSpeedSheet(it).show(supportFragmentManager) }
|
||||
}
|
||||
|
@ -67,6 +67,15 @@
|
||||
android:layout_gravity="center"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/autoPlay"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:visibility="gone"
|
||||
app:trackTint="#88ffffff"
|
||||
app:thumbTint="@android:color/white"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_toggle"
|
||||
style="@style/PlayerControlTop"
|
||||
|
Loading…
x
Reference in New Issue
Block a user