fix(player): show clear-queue confirmation when tapping a new video#55
Open
Rumi-sketches wants to merge 1 commit into
Open
Conversation
The "ask for confirmation before clearing a queue" setting only worked when switching the same video between player types (popup/background/ main player). It never fired when tapping a different video from the feed, search results, or the related-items list under an expanded player, which is the setting's main use case. Root cause: selectAndLoadVideo() (the entry point used by all of the above) had no confirmation check at all. By the time the existing replaceQueueIfUserConfirms() check ran later in the flow (via runWorker's autoplay path), hideMainPlayerOnLoadingNewStream() had already torn down the active player/queue, so the check always saw no active queue to protect. Add loadVideoIfUserConfirms(), evaluated synchronously at the top of selectAndLoadVideo() before anything is torn down. It compares the live player's current queue item against the URL about to be loaded, since at this point playQueue/url still reflect the *old* target. Also only ask for confirmation when the active queue actually has more than one item; replacing a lone, queue-less video should just play the new one immediately.
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.
Summary
The "ask for confirmation before clearing a queue" setting only worked when switching the same video between player types (popup/background/main player), It never fired when tapping a different video.
The setting's actual main use case, whether from the feed, search results, or the related-items list under an expanded player.
Problem
selectAndLoadVideo(), the entry point used whenever a different video is opened from any list, had no confirmation check of its own. The existing check (replaceQueueIfUserConfirms) only ran later, inside the autoplay path triggered after the new stream's info finished loading. By that point,hideMainPlayerOnLoadingNewStream()had already torn down the active player/queue (playerHolder.stopService()), so the check always sawactiveQueue == nulland silently skipped the confirmation — regardless of the setting.Changes
loadVideoIfUserConfirms(), evaluated synchronously at the very top ofselectAndLoadVideo(), before anything is torn down. It compares the live player's current queue item against the URL about to be loaded (sinceplayQueue/urlstill reflect the old target at this point).replaceQueueIfUserConfirmsand the newloadVideoIfUserConfirms) now also require the active queue to have more than one item — replacing a lone, queue-less video just plays the new one immediately, no popup.Validation
Manually tested on-device (OnePlus Open):
nullby the time the original check ran.