Now Playing Integration Guide
Purpose: Prevent the 4 most common Now Playing issues on iOS 18+: info not appearing, commands not working, artwork problems, and state sync issues
Swift Version: Swift 6.0+
iOS Version: iOS 18+
Xcode: Xcode 16+
Core Philosophy
"Now Playing eligibility requires THREE things working together: AVAudioSession activation, remote command handlers, and metadata publishing. Missing ANY of these silently breaks the entire system. 90% of Now Playing issues stem from incorrect activation order or missing command handlers, not API bugs."
Key Insight from WWDC 2022/110338: Apps must meet two system heuristics:
- Register handlers for at least one remote command
- Configure AVAudioSession with a non-mixable category
When to Use This Skill
β
Use this skill when:
- Now Playing info doesn't appear on Lock Screen or Control Center
- Play/pause/skip buttons are grayed out or don't respond
- Album artwork is missing, wrong, or flickers between images
- Control Center shows "Playing" when app is paused, or vice versa
- Apple Music or other apps "steal" Now Playing status
- Implementing Now Playing for the first time
- Debugging Now Playing issues in existing implementation
- Integrating CarPlay Now Playing (covered in Pattern 6)
- Working with MusicKit/Apple Music content (covered in Pattern 7)
iOS 26 Note
iOS 26 introduces Liquid Glass visual design for Lock Screen and Control Center Now Playing widgets. This is automatic system behavior β no code changes required. The patterns in this skill remain valid for iOS 26.
β Do NOT use this skill for:
- Background audio configuration details (see AVFoundation skill)
Related Skills
- swift-concurrency - For @MainActor patterns, weak self in closures, async artwork loading
- memory-debugging - For retain cycles in command handlers
- avfoundation-ref - For AVAudioSession configuration details
Red Flags / Anti-Patterns
If you see ANY of these, suspect Now Playing misconfiguration:
- Info appears briefly then disappears (AVAudioSession deactivated)
- Commands work in simulator but not on device (simulator has different audio stack)
- Artwork shows placeholder then updates (race condition, not necessarily wrong)
- Artwork never appears (format/size issue or MPMediaItemArtwork block returning nil)
- Play/pause state incorrect after backgrounding (not updating on playback rate changes)
- Another app "steals" Now Playing (didn't meet eligibility requirements)
playbackState property doesn't update (iOS doesn't have playbackState, macOS only!)
FORBIDDEN Assumptions:
- "Just set nowPlayingInfo and it works" - Must have AVAudioSession + command handlers
- "playbackState controls Control Center" - iOS ignores playbackState, uses playbackRate
- "Artwork just needs an image" - Needs proper MPMediaItemArtwork with size handler
- "Commands enable themselves" - Must add target AND set isEnabled = true
- "Update elapsed time every second" - System infers from rate, causes jitter
Mandatory First Steps (Pre-Diagnosis)
Run this code to understand current state before debugging:
let session = AVAudioSession.sharedInstance()
print("Category: \(session.category.rawValue)")
print("Mode: \(session.mode.rawValue)")
print("Options: \(session.categoryOptions)")
print("Is active: \(try? session.setActive(true))")
let commandCenter = MPRemoteCommandCenter.shared()
print("Play enabled: \(commandCenter.playCommand.isEnabled)")
print("Pause enabled: \(commandCenter.pauseCommand.isEnabled)")
if let info = MPNowPlayingInfoCenter.default().nowPlayingInfo {
print("Title: \(info[MPMediaItemPropertyTitle] ?? "nil")")
print("Artwork: \(info[MPMediaItemPropertyArtwork] != nil)")
print("Duration: \(info[MPMediaItemPropertyPlaybackDuration] ?? "nil")")
print("Elapsed: \(info[MPNowPlayingInfoPropertyElapsedPlaybackTime] ?? "nil")")
print("Rate: \(info[MPNowPlayingInfoPropertyPlaybackRate] ?? "nil")")
} else {
print("No nowPlayingInfo set!")
}
What this tells you:
| Observation |
Diagnosis |
Pattern |
| Category is .ambient or has .mixWithOthers |
Won't become Now Playing app |
Pattern 1 |
| No commands have targets |
System ignores app |
Pattern 2 |
| Commands have targets but isEnabled = false |
UI grayed out |
Pattern 2 |
| Artwork is nil |
MPMediaItemArtwork block returning nil |
Pattern 3 |
| playbackRate is 0.0 when playing |
Control Center shows paused |
Pattern 4 |
| Background mode "audio" not in Info.plist |
Info disappears on lock |
Pattern 1 |
Decision Tree
Now Playing not working?
ββ Info never appears at all?
β ββ AVAudioSession category .ambient or .mixWithOthers?
β β ββ Pattern 1a (Wrong Category)
β ββ No remote command handlers registered?
β β ββ Pattern 2a (Missing Handlers)
β ββ Background mode "audio" not in Info.plist?
β β ββ Pattern 1b (Background Mode)
β ββ AVAudioSession.setActive(true) never called?
β ββ Pattern 1c (Not Activated)
β
ββ Info appears briefly, then disappears?
β ββ On lock screen specifically?
β β ββ AVAudioSession deactivated too early?
β β β ββ Pattern 1d (Early Deactivation)
β β ββ App suspended (no background mode)?
β β ββ Pattern 1b (Background Mode)
β ββ When switching apps?
β ββ Another app claiming Now Playing β Pattern 5
β
ββ Commands not responding?
β ββ Buttons grayed out (disabled)?
β β ββ command.isEnabled = false β Pattern 2b
β ββ Buttons visible but no response?
β β ββ Handler not returning .success?
β β β ββ Pattern 2c (Handler Return)
β β ββ Using wrong command center (session vs shared)?
β β ββ Pattern 2d (Command Center)
β ββ Skip forward/backward not showing?
β ββ preferredIntervals not set β Pattern 2e
β
ββ Artwork problems?
β ββ Never appears?
β β ββ MPMediaItemArtwork block returning nil?
β β β ββ Pattern 3a (Artwork Block)
β β ββ Image format/size invalid?
β β ββ Pattern 3b (Image Format)
β ββ Wrong artwork showing?
β β ββ Race condition between sources β Pattern 3c
β ββ Artwork flickering?
β ββ Multiple updates in rapid succession β Pattern 3d
β
ββ State sync issues?
β ββ Shows "Playing" when paused?
β β ββ playbackRate not updated β Pattern 4a
β ββ Progress bar stuck or jumping?
β β ββ elapsedTime not updated at right moments β Pattern 4b
β ββ Duration wrong?
β ββ Not setting playbackDuration β Pattern 4c
β
ββ CarPlay specific issues?
β ββ App doesn't appear in CarPlay at all?
β β ββ Missing entitlement β Pattern 6 (Add com.apple.developer.carplay-audio)
β ββ Now Playing blank in CarPlay but works on iOS?
β β ββ Same root cause as iOS β Check Patterns 1-4
β ββ Custom buttons don't appear in CarPlay?
β β ββ Wrong configuration timing β Pattern 6 (Configure at templateApplicationScene)
β ββ Works on device but not CarPlay simulator?
β ββ Debugger interference β Pattern 6 (Run without debugger)
β
ββ Using MusicKit (ApplicationMusicPlayer)?
ββ Now Playing shows wrong info?
β ββ Overwriting automatic data β Pattern 7 (Don't set nowPlayingInfo manually)
ββ Mixing MusicKit + own content?
ββ Hybrid approach needed β Pattern 7 (Switch between players)
Pattern 1: AVAudioSession Configuration (Info Not Appearing)
Time cost: 10-15 minutes
Symptom
- Now Playing info never appears on Lock Screen
- Info appears briefly then disappears on lock
- Works in foreground, disappears in background
BAD Code
class PlayerService {
func setupAudioSession() throws {
try AVAudioSession.sharedInstance().setCategory(
.playback,
options: .mixWithOthers
)
}
func play() {
player.play()
updateNowPlaying()
}
}
GOOD Code
class PlayerService {
func setupAudioSession() throws {
try AVAudioSession.sharedInstance().setCategory(
.playback,
mode: .default,
options: []
)
}
func play