feat(ios): add iosNextPreviousCommandsSkip option for AirPods seek support#2584
Open
anojht wants to merge 1 commit intodoublesymmetry:mainfrom
Open
feat(ios): add iosNextPreviousCommandsSkip option for AirPods seek support#2584anojht wants to merge 1 commit intodoublesymmetry:mainfrom
anojht wants to merge 1 commit intodoublesymmetry:mainfrom
Conversation
…pport Add a new `iosNextPreviousCommandsSkip` option to `updateOptions()` that registers `nextTrackCommand` and `previousTrackCommand` on `MPRemoteCommandCenter` with handlers that seek by the configured jump intervals instead of skipping tracks. This enables AirPods double-press (seek forward) and triple-press (seek backward) without affecting the lock screen / Control Center UI, which continues to show the skip-interval buttons when `JumpForward` and `JumpBackward` are in the capabilities array. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Adds a new
iosNextPreviousCommandsSkipoption toupdateOptions()that enables AirPods double-press (seek forward) and triple-press (seek backward) for podcast and audiobook apps, without changing the lock screen / Control Center button layout.Problem
Podcast and audiobook apps typically configure their lock screen controls with
Capability.JumpForwardandCapability.JumpBackwardto show skip-interval buttons (e.g., "15s back", "30s forward") instead of next/previous track arrows. However, this means AirPods double-press and triple-press do nothing because:Capability.Skipis a NOOP on iOS — it maps to"NOOP"in the constants dictionary and registers no commandsCapability.SkipToNext/Capability.SkipToPreviousregisternextTrackCommand/previousTrackCommand, which changes the lock screen UI to show next/previous track arrows, replacing the skip-interval buttonsThere is currently no way to:
JumpForward/JumpBackward)This is a common requirement for podcast apps — Apple's own Podcasts app supports this exact behavior.
Solution
A new
iosNextPreviousCommandsSkipboolean option inupdateOptions()that, whentrue:nextTrackCommandandpreviousTrackCommandhandlers onMPRemoteCommandCenter.shared()outside of the RNTP capabilities systemplayer.seek()using the configuredforwardJumpInterval/backwardJumpIntervalplayer.remoteCommands, so they don't affect the lock screen button layoutWhy register outside the capabilities system?
The RNTP capabilities array maps 1:1 to
player.remoteCommands, which SwiftAudioEx uses to determine both the command handlers AND the lock screen UI. By registering directly onMPRemoteCommandCenter.shared(), we decouple the AirPods command handling from the lock screen layout.How AirPods commands work on iOS
AirPods button presses map to
MPRemoteCommandCentercommands:togglePlayPauseCommandnextTrackCommandpreviousTrackCommandThese are hardware-level mappings that cannot be changed. The only way to make double-press seek forward is to register a
nextTrackCommandhandler that performs a seek.Usage
Lock screen result: Shows skip-interval buttons (⟲15 advancement advancement advancement ▶ ⟳30) — same as without the option.
AirPods result:
forwardJumpInterval(30s)backwardJumpInterval(15s)Changes
src/interfaces/UpdateOptions.tsiosNextPreviousCommandsSkip?: booleanwith JSDoc documentationios/TrackPlayer.swiftnextPreviousCommandTargetsinstance property to track registered command targets for cleanupconfigureNextPreviousAsSkip(enabled:)private method that:nextTrackCommandandpreviousTrackCommandonMPRemoteCommandCenter.shared()with seek handlersupdate(options:resolve:reject:)afterplayer.remoteCommandsis setBackward compatibility
false— no behavior change for existing usersCapability.SkipToNext/Capability.SkipToPreviousif they are also in the capabilities arrayupdateOptions()callsTest plan
iosNextPreviousCommandsSkip: truewithJumpForward/JumpBackwardin capabilitiesforwardJumpIntervalbackwardJumpIntervaliosNextPreviousCommandsSkip: false(or omit)updateOptions()multiple times togglingiosNextPreviousCommandsSkipSkipToNext/SkipToPreviousin capabilities simultaneouslyforwardJumpInterval/backwardJumpIntervalvalues🤖 Generated with Claude Code