mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-09-12 12:32:27 +00:00
casting: minimize diff
This commit is contained in:
parent
f21ed9aa2a
commit
f27022a3dc
4 changed files with 27 additions and 32 deletions
|
@ -7,6 +7,7 @@ import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Animatable
|
import android.graphics.drawable.Animatable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.text.Layout
|
||||||
import android.text.method.ScrollingMovementMethod
|
import android.text.method.ScrollingMovementMethod
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
|
@ -436,7 +437,7 @@ class UIDialogs {
|
||||||
|
|
||||||
|
|
||||||
fun showCastingDialog(context: Context, ownerActivity: Activity? = null) {
|
fun showCastingDialog(context: Context, ownerActivity: Activity? = null) {
|
||||||
val d = StateCasting.instance.activeDevice
|
val d = StateCasting.instance.activeDevice;
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
val dialog = ConnectedCastingDialog(context);
|
val dialog = ConnectedCastingDialog(context);
|
||||||
if (context is Activity) {
|
if (context is Activity) {
|
||||||
|
|
|
@ -91,11 +91,13 @@ class DeviceViewHolder : ViewHolder {
|
||||||
_textType.text = "AirPlay";
|
_textType.text = "AirPlay";
|
||||||
}
|
}
|
||||||
CastProtocolType.FCAST -> {
|
CastProtocolType.FCAST -> {
|
||||||
|
_imageDevice.setImageResource(
|
||||||
if (Settings.instance.casting.experimentalCasting) {
|
if (Settings.instance.casting.experimentalCasting) {
|
||||||
_imageDevice.setImageResource(R.drawable.ic_exp_fc)
|
R.drawable.ic_exp_fc
|
||||||
} else {
|
} else {
|
||||||
_imageDevice.setImageResource(R.drawable.ic_fc);
|
R.drawable.ic_fc
|
||||||
}
|
}
|
||||||
|
)
|
||||||
_textType.text = "FCast";
|
_textType.text = "FCast";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +105,6 @@ class DeviceViewHolder : ViewHolder {
|
||||||
_textName.text = d.name;
|
_textName.text = d.name;
|
||||||
_imageOnline.visibility = if (isOnlineDevice && d.isReady) View.VISIBLE else View.GONE
|
_imageOnline.visibility = if (isOnlineDevice && d.isReady) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
|
|
||||||
if (!d.isReady) {
|
if (!d.isReady) {
|
||||||
_imageLoader.visibility = View.GONE;
|
_imageLoader.visibility = View.GONE;
|
||||||
_textNotReady.visibility = View.VISIBLE;
|
_textNotReady.visibility = View.VISIBLE;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import androidx.core.content.ContextCompat
|
||||||
import com.futo.platformplayer.R
|
import com.futo.platformplayer.R
|
||||||
import com.futo.platformplayer.Settings
|
import com.futo.platformplayer.Settings
|
||||||
import com.futo.platformplayer.UIDialogs
|
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.casting.StateCasting
|
||||||
import com.futo.platformplayer.constructs.Event1
|
import com.futo.platformplayer.constructs.Event1
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ class CastButton : androidx.appcompat.widget.AppCompatImageButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
StateCasting.instance.onActiveDeviceConnectionStateChanged.subscribe(this) { _, _ ->
|
StateCasting.instance.onActiveDeviceConnectionStateChanged.subscribe(this) { _, _ ->
|
||||||
updateCastState()
|
updateCastState();
|
||||||
}
|
};
|
||||||
|
|
||||||
updateCastState();
|
updateCastState();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ class CastButton : androidx.appcompat.widget.AppCompatImageButton {
|
||||||
|
|
||||||
private fun updateCastState() {
|
private fun updateCastState() {
|
||||||
val c = context ?: return;
|
val c = context ?: return;
|
||||||
|
|
||||||
val d = StateCasting.instance.activeDevice;
|
val d = StateCasting.instance.activeDevice;
|
||||||
|
|
||||||
val activeColor = ContextCompat.getColor(c, R.color.colorPrimary);
|
val activeColor = ContextCompat.getColor(c, R.color.colorPrimary);
|
||||||
|
@ -41,9 +40,9 @@ class CastButton : androidx.appcompat.widget.AppCompatImageButton {
|
||||||
|
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
when (d.connectionState) {
|
when (d.connectionState) {
|
||||||
DISCONNECTED -> setColorFilter(activeColor)
|
CastConnectionState.DISCONNECTED -> setColorFilter(activeColor)
|
||||||
CONNECTING -> setColorFilter(connectingColor)
|
CastConnectionState.CONNECTING -> setColorFilter(connectingColor)
|
||||||
CONNECTED -> setColorFilter(activeColor)
|
CastConnectionState.CONNECTED -> setColorFilter(activeColor)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setColorFilter(inactiveColor);
|
setColorFilter(inactiveColor);
|
||||||
|
|
|
@ -94,7 +94,7 @@ class CastView : ConstraintLayout {
|
||||||
_gestureControlView.fullScreenGestureEnabled = false
|
_gestureControlView.fullScreenGestureEnabled = false
|
||||||
_gestureControlView.setupTouchArea();
|
_gestureControlView.setupTouchArea();
|
||||||
_gestureControlView.onSpeedHoldStart.subscribe {
|
_gestureControlView.onSpeedHoldStart.subscribe {
|
||||||
val d = StateCasting.instance.activeDevice ?: return@subscribe
|
val d = StateCasting.instance.activeDevice ?: return@subscribe;
|
||||||
_speedHoldWasPlaying = d.isPlaying
|
_speedHoldWasPlaying = d.isPlaying
|
||||||
_speedHoldPrevRate = d.speed
|
_speedHoldPrevRate = d.speed
|
||||||
try {
|
try {
|
||||||
|
@ -119,9 +119,8 @@ class CastView : ConstraintLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
_gestureControlView.onSeek.subscribe {
|
_gestureControlView.onSeek.subscribe {
|
||||||
val d = StateCasting.instance.activeDevice ?: return@subscribe
|
val d = StateCasting.instance.activeDevice ?: return@subscribe;
|
||||||
val expectedCurrentTime = d.expectedCurrentTime
|
StateCasting.instance.videoSeekTo( d.expectedCurrentTime + it / 1000);
|
||||||
StateCasting.instance.videoSeekTo(expectedCurrentTime + it / 1000)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_buttonLoop.setOnClickListener {
|
_buttonLoop.setOnClickListener {
|
||||||
|
@ -132,26 +131,22 @@ class CastView : ConstraintLayout {
|
||||||
|
|
||||||
_timeBar.addListener(object : TimeBar.OnScrubListener {
|
_timeBar.addListener(object : TimeBar.OnScrubListener {
|
||||||
override fun onScrubStart(timeBar: TimeBar, position: Long) {
|
override fun onScrubStart(timeBar: TimeBar, position: Long) {
|
||||||
StateCasting.instance.videoSeekTo(position.toDouble())
|
StateCasting.instance.videoSeekTo(position.toDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScrubMove(timeBar: TimeBar, position: Long) {
|
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) {
|
override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) {
|
||||||
StateCasting.instance.videoSeekTo(position.toDouble())
|
StateCasting.instance.videoSeekTo(position.toDouble());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_buttonMinimize.setOnClickListener { onMinimizeClick.emit(); };
|
_buttonMinimize.setOnClickListener { onMinimizeClick.emit(); };
|
||||||
_buttonSettings.setOnClickListener { onSettingsClick.emit(); };
|
_buttonSettings.setOnClickListener { onSettingsClick.emit(); };
|
||||||
_buttonPlay.setOnClickListener {
|
_buttonPlay.setOnClickListener { StateCasting.instance.resumeVideo(); };
|
||||||
StateCasting.instance.resumeVideo()
|
_buttonPause.setOnClickListener { StateCasting.instance.pauseVideo(); };
|
||||||
}
|
|
||||||
_buttonPause.setOnClickListener {
|
|
||||||
StateCasting.instance.pauseVideo()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isInEditMode) {
|
if (!isInEditMode) {
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
|
@ -248,7 +243,7 @@ class CastView : ConstraintLayout {
|
||||||
_buttonPlay.visibility = View.VISIBLE;
|
_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()) {
|
if(StatePlayer.instance.hasMediaSession()) {
|
||||||
StatePlayer.instance.updateMediaSession(null);
|
StatePlayer.instance.updateMediaSession(null);
|
||||||
StatePlayer.instance.updateMediaSessionPlaybackState(getPlaybackStateCompat(), (position ?: 0));
|
StatePlayer.instance.updateMediaSessionPlaybackState(getPlaybackStateCompat(), (position ?: 0));
|
||||||
|
@ -312,10 +307,9 @@ class CastView : ConstraintLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPlaybackStateCompat(): Int {
|
private fun getPlaybackStateCompat(): Int {
|
||||||
if (StateCasting.instance.activeDevice?.connectionState != CastConnectionState.CONNECTED) {
|
val d = StateCasting.instance.activeDevice ?: return PlaybackState.STATE_NONE;
|
||||||
return PlaybackState.STATE_NONE
|
|
||||||
}
|
return when(d.isPlaying) {
|
||||||
return when(StateCasting.instance.activeDevice?.isPlaying) {
|
|
||||||
true -> PlaybackStateCompat.STATE_PLAYING;
|
true -> PlaybackStateCompat.STATE_PLAYING;
|
||||||
else -> PlaybackStateCompat.STATE_PAUSED;
|
else -> PlaybackStateCompat.STATE_PAUSED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue