Cast synchronize tracks#1151
Merged
StaehliJ merged 7 commits into928-custom-castplayerfrom Sep 1, 2025
Merged
Conversation
MGaetan89
approved these changes
Aug 29, 2025
Contributor
MGaetan89
left a comment
There was a problem hiding this comment.
A couple of minor suggestions, but looks good to me otherwise 👍🏻
| import ch.srgssr.pillarbox.demo.ui.player.DemoPlayerView | ||
| import ch.srgssr.pillarbox.demo.ui.player.playlist.PlaylistView | ||
| import ch.srgssr.pillarbox.ui.exoplayer.ExoPlayerView | ||
| import androidx.compose.ui.graphics.Color as ComposeColor |
Contributor
There was a problem hiding this comment.
Now that we don't use android.graphics.Color anymore, you can remove the alias here.
| .map { if (it) castPlayer else localPlayer } | ||
| .distinctUntilChanged() | ||
| .onEach { switchPlayer(it) } | ||
| .stateIn(coroutineScope, SharingStarted.Companion.WhileSubscribed(5_000), if (castContext.isConnected()) castPlayer else localPlayer) |
Contributor
There was a problem hiding this comment.
Suggested change
| .stateIn(coroutineScope, SharingStarted.Companion.WhileSubscribed(5_000), if (castContext.isConnected()) castPlayer else localPlayer) | |
| .stateIn(coroutineScope, SharingStarted.WhileSubscribed(5_000), if (castContext.isConnected()) castPlayer else localPlayer) |
| private fun switchPlayer(player: PillarboxPlayer) { | ||
| val oldPlayer = if (player is PillarboxCastPlayer) localPlayer else castPlayer | ||
| if (oldPlayer == player || (oldPlayer == localPlayer && oldPlayer.playbackState == Player.STATE_IDLE)) return | ||
| val selectedAudio = oldPlayer.currentTracks.audioTracks.firstOrNull { it.isSelected } |
Contributor
There was a problem hiding this comment.
Suggested change
| val selectedAudio = oldPlayer.currentTracks.audioTracks.firstOrNull { it.isSelected } | |
| val selectedAudioTrack = oldPlayer.currentTracks.audioTracks.firstOrNull { it.isSelected } |
Code Coverage
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request
Description
The goal of this PR is to help integrators to managed transition between local and remote playback. The audio and text track selection can be transferred between remote and local. The current default behavior tries to select the first track that matches the same language.
Changes made
CastPlayerSynchronizerthat handle the transition between remote and local player.PlayerSynchronizerto customize player states when the transition occured.Checklist