casting: minimize diff

This commit is contained in:
Marcus Hanestad 2025-09-04 14:00:43 +02:00
commit f27022a3dc
4 changed files with 27 additions and 32 deletions

View file

@ -7,6 +7,7 @@ import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.Animatable
import android.net.Uri
import android.text.Layout
import android.text.method.ScrollingMovementMethod
import android.util.TypedValue
import android.view.Gravity
@ -436,7 +437,7 @@ class UIDialogs {
fun showCastingDialog(context: Context, ownerActivity: Activity? = null) {
val d = StateCasting.instance.activeDevice
val d = StateCasting.instance.activeDevice;
if (d != null) {
val dialog = ConnectedCastingDialog(context);
if (context is Activity) {

View file

@ -91,11 +91,13 @@ class DeviceViewHolder : ViewHolder {
_textType.text = "AirPlay";
}
CastProtocolType.FCAST -> {
if (Settings.instance.casting.experimentalCasting) {
_imageDevice.setImageResource(R.drawable.ic_exp_fc)
} else {
_imageDevice.setImageResource(R.drawable.ic_fc);
}
_imageDevice.setImageResource(
if (Settings.instance.casting.experimentalCasting) {
R.drawable.ic_exp_fc
} else {
R.drawable.ic_fc
}
)
_textType.text = "FCast";
}
}
@ -103,7 +105,6 @@ class DeviceViewHolder : ViewHolder {
_textName.text = d.name;
_imageOnline.visibility = if (isOnlineDevice && d.isReady) View.VISIBLE else View.GONE
if (!d.isReady) {
_imageLoader.visibility = View.GONE;
_textNotReady.visibility = View.VISIBLE;

View file

@ -7,7 +7,7 @@ import androidx.core.content.ContextCompat
import com.futo.platformplayer.R
import com.futo.platformplayer.Settings
import com.futo.platformplayer.UIDialogs
import com.futo.platformplayer.casting.CastConnectionState.*
import com.futo.platformplayer.casting.CastConnectionState
import com.futo.platformplayer.casting.StateCasting
import com.futo.platformplayer.constructs.Event1
@ -23,8 +23,8 @@ class CastButton : androidx.appcompat.widget.AppCompatImageButton {
}
StateCasting.instance.onActiveDeviceConnectionStateChanged.subscribe(this) { _, _ ->
updateCastState()
}
updateCastState();
};
updateCastState();
}
@ -32,7 +32,6 @@ class CastButton : androidx.appcompat.widget.AppCompatImageButton {
private fun updateCastState() {
val c = context ?: return;
val d = StateCasting.instance.activeDevice;
val activeColor = ContextCompat.getColor(c, R.color.colorPrimary);
@ -41,9 +40,9 @@ class CastButton : androidx.appcompat.widget.AppCompatImageButton {
if (d != null) {
when (d.connectionState) {
DISCONNECTED -> setColorFilter(activeColor)
CONNECTING -> setColorFilter(connectingColor)
CONNECTED -> setColorFilter(activeColor)
CastConnectionState.DISCONNECTED -> setColorFilter(activeColor)
CastConnectionState.CONNECTING -> setColorFilter(connectingColor)
CastConnectionState.CONNECTED -> setColorFilter(activeColor)
}
} else {
setColorFilter(inactiveColor);

View file

@ -94,7 +94,7 @@ class CastView : ConstraintLayout {
_gestureControlView.fullScreenGestureEnabled = false
_gestureControlView.setupTouchArea();
_gestureControlView.onSpeedHoldStart.subscribe {
val d = StateCasting.instance.activeDevice ?: return@subscribe
val d = StateCasting.instance.activeDevice ?: return@subscribe;
_speedHoldWasPlaying = d.isPlaying
_speedHoldPrevRate = d.speed
try {
@ -119,9 +119,8 @@ class CastView : ConstraintLayout {
}
_gestureControlView.onSeek.subscribe {
val d = StateCasting.instance.activeDevice ?: return@subscribe
val expectedCurrentTime = d.expectedCurrentTime
StateCasting.instance.videoSeekTo(expectedCurrentTime + it / 1000)
val d = StateCasting.instance.activeDevice ?: return@subscribe;
StateCasting.instance.videoSeekTo( d.expectedCurrentTime + it / 1000);
};
_buttonLoop.setOnClickListener {
@ -132,26 +131,22 @@ class CastView : ConstraintLayout {
_timeBar.addListener(object : TimeBar.OnScrubListener {
override fun onScrubStart(timeBar: TimeBar, position: Long) {
StateCasting.instance.videoSeekTo(position.toDouble())
StateCasting.instance.videoSeekTo(position.toDouble());
}
override fun onScrubMove(timeBar: TimeBar, position: Long) {
StateCasting.instance.videoSeekTo(position.toDouble())
StateCasting.instance.videoSeekTo(position.toDouble());
}
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {
StateCasting.instance.videoSeekTo(position.toDouble())
StateCasting.instance.videoSeekTo(position.toDouble());
}
});
_buttonMinimize.setOnClickListener { onMinimizeClick.emit(); };
_buttonSettings.setOnClickListener { onSettingsClick.emit(); };
_buttonPlay.setOnClickListener {
StateCasting.instance.resumeVideo()
}
_buttonPause.setOnClickListener {
StateCasting.instance.pauseVideo()
}
_buttonPlay.setOnClickListener { StateCasting.instance.resumeVideo(); };
_buttonPause.setOnClickListener { StateCasting.instance.pauseVideo(); };
if (!isInEditMode) {
setIsPlaying(false);
@ -248,7 +243,7 @@ class CastView : ConstraintLayout {
_buttonPlay.visibility = View.VISIBLE;
}
val position = StateCasting.instance.activeDevice?.expectedCurrentTime?.times(1000.0)?.toLong()
val position = StateCasting.instance.activeDevice?.expectedCurrentTime?.times(1000.0)?.toLong();
if(StatePlayer.instance.hasMediaSession()) {
StatePlayer.instance.updateMediaSession(null);
StatePlayer.instance.updateMediaSessionPlaybackState(getPlaybackStateCompat(), (position ?: 0));
@ -312,10 +307,9 @@ class CastView : ConstraintLayout {
}
private fun getPlaybackStateCompat(): Int {
if (StateCasting.instance.activeDevice?.connectionState != CastConnectionState.CONNECTED) {
return PlaybackState.STATE_NONE
}
return when(StateCasting.instance.activeDevice?.isPlaying) {
val d = StateCasting.instance.activeDevice ?: return PlaybackState.STATE_NONE;
return when(d.isPlaying) {
true -> PlaybackStateCompat.STATE_PLAYING;
else -> PlaybackStateCompat.STATE_PAUSED;
}