fix: default to old cast method for now
This commit is contained in:
parent
bfe4d69b8a
commit
4aa88244ed
6 changed files with 68 additions and 11 deletions
|
@ -1079,17 +1079,17 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
|
||||
//Cast
|
||||
if (PrefManager.getVal(PrefName.Cast)) {
|
||||
playerView.findViewById<MediaRouteButton>(R.id.exo_cast).apply {
|
||||
playerView.findViewById<CustomCastButton>(R.id.exo_cast).apply {
|
||||
visibility = View.VISIBLE
|
||||
try {
|
||||
CastButtonFactory.setUpMediaRouteButton(context, this)
|
||||
dialogFactory = CustomCastThemeFactory()
|
||||
} catch (e: Exception) {
|
||||
isCastApiAvailable = false
|
||||
}
|
||||
setOnLongClickListener {
|
||||
cast()
|
||||
true
|
||||
if(PrefManager.getVal(PrefName.UseInternalCast)) {
|
||||
try {
|
||||
CastButtonFactory.setUpMediaRouteButton(context, this)
|
||||
dialogFactory = CustomCastThemeFactory()
|
||||
} catch (e: Exception) {
|
||||
isCastApiAvailable = false
|
||||
}
|
||||
} else {
|
||||
setCastCallback { cast() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2004,3 +2004,31 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CustomCastButton : MediaRouteButton {
|
||||
|
||||
private var castCallback: (() -> Unit)? = null
|
||||
|
||||
fun setCastCallback(castCallback: () -> Unit) {
|
||||
this.castCallback = castCallback
|
||||
}
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, castCallback: () -> Unit) : super(context, attrs) {
|
||||
this.castCallback = castCallback
|
||||
}
|
||||
|
||||
|
||||
override fun performClick(): Boolean {
|
||||
return if (PrefManager.getVal(PrefName.UseInternalCast)) {
|
||||
super.performClick()
|
||||
} else {
|
||||
castCallback?.let { it() }
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -234,6 +234,11 @@ class PlayerSettingsActivity : AppCompatActivity() {
|
|||
PrefManager.setVal(PrefName.Cast, isChecked)
|
||||
}
|
||||
|
||||
binding.playerSettingsInternalCast.isChecked = PrefManager.getVal(PrefName.UseInternalCast)
|
||||
binding.playerSettingsInternalCast.setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.UseInternalCast, isChecked)
|
||||
}
|
||||
|
||||
binding.playerSettingsRotate.isChecked = PrefManager.getVal(PrefName.RotationPlayer)
|
||||
binding.playerSettingsRotate.setOnCheckedChangeListener { _, isChecked ->
|
||||
PrefManager.setVal(PrefName.RotationPlayer, isChecked)
|
||||
|
|
|
@ -94,6 +94,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
|||
SeekTime(Pref(Location.Player, Int::class, 10)),
|
||||
SkipTime(Pref(Location.Player, Int::class, 85)),
|
||||
Cast(Pref(Location.Player, Boolean::class, true)),
|
||||
UseInternalCast(Pref(Location.Player, Boolean::class, false)),
|
||||
Pip(Pref(Location.Player, Boolean::class, true)),
|
||||
RotationPlayer(Pref(Location.Player, Boolean::class, true)),
|
||||
ContinuedAnime(Pref(Location.Player, List::class, listOf<String>())),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue