On casting device disconnect, only set play when ready to true if it was also playing on the TV device.

This commit is contained in:
Koen J 2025-07-24 13:44:04 +02:00
commit 1fb55dca0a

View file

@ -649,7 +649,7 @@ class VideoDetailView : ConstraintLayout {
} }
if (!isInEditMode) { if (!isInEditMode) {
StateCasting.instance.onActiveDeviceConnectionStateChanged.subscribe(this) { _, connectionState -> StateCasting.instance.onActiveDeviceConnectionStateChanged.subscribe(this) { device, connectionState ->
if (_onPauseCalled) { if (_onPauseCalled) {
return@subscribe; return@subscribe;
} }
@ -661,7 +661,7 @@ class VideoDetailView : ConstraintLayout {
setCastEnabled(true); setCastEnabled(true);
} }
CastConnectionState.DISCONNECTED -> { CastConnectionState.DISCONNECTED -> {
loadCurrentVideo(lastPositionMilliseconds); loadCurrentVideo(lastPositionMilliseconds, playWhenReady = device.isPlaying);
updatePillButtonVisibilities(); updatePillButtonVisibilities();
setCastEnabled(false); setCastEnabled(false);
@ -1880,7 +1880,7 @@ class VideoDetailView : ConstraintLayout {
} }
//Source Loads //Source Loads
private fun loadCurrentVideo(resumePositionMs: Long = 0) { private fun loadCurrentVideo(resumePositionMs: Long = 0, playWhenReady: Boolean = true) {
_didStop = false; _didStop = false;
val video = (videoLocal ?: video) ?: return; val video = (videoLocal ?: video) ?: return;
@ -1925,7 +1925,7 @@ class VideoDetailView : ConstraintLayout {
else else
_player.setArtwork(null); _player.setArtwork(null);
} }
_player.setSource(videoSource, audioSource, _playWhenReady, false, resume = resumePositionMs > 0); _player.setSource(videoSource, audioSource, _playWhenReady && playWhenReady, false, resume = resumePositionMs > 0);
if(subtitleSource != null) if(subtitleSource != null)
_player.swapSubtitles(fragment.lifecycleScope, subtitleSource); _player.swapSubtitles(fragment.lifecycleScope, subtitleSource);
_player.seekTo(resumePositionMs); _player.seekTo(resumePositionMs);