Skip to content

feat: show audio on the Lock Screen and support AirPlay - #4504

Open
SimonStMichel wants to merge 1 commit into
nextcloud:masterfrom
SimonStMichel:feat/audio-now-playing-airplay
Open

SimonStMichel wants to merge 1 commit into
nextcloud:masterfrom
SimonStMichel:feat/audio-now-playing-airplay

Conversation

@SimonStMichel

Copy link
Copy Markdown

Problem

Audio opened in the media viewer keeps playing when the phone is locked, but it never shows up on the Lock Screen or in Control Center. To pause or skip, you have to unlock the phone and go back to the app. Because the app has no Now Playing session, it is also missing from Control Center's AirPlay picker, and the audio screen has no AirPlay button, so music stored on Nextcloud can't be sent to AirPlay speakers such as Sonos.

What changed

  • The playing audio file now appears on the Lock Screen, in Control Center and in the Dynamic Island, with title, artist, album and cover art. These come from the file's embedded tags, or from the file name and server preview when the file has no tags.
  • Play/Pause, −10/+10 s and dragging the progress bar work from those controls and from headphone buttons. The controls disappear when the viewer closes or another page is selected.
  • The audio screen has an AirPlay button (the existing video picker, reused), and the app is available in Control Center's AirPlay picker.
  • Audio uses the long-form route sharing policy, which Apple recommends for music and AirPlay 2 receivers.

The new NCAudioNowPlayingController connects the existing NCAudioViewerModel to MPNowPlayingInfoCenter and MPRemoteCommandCenter. Only the model that started playing owns the session, so the neighboring pages the viewer keeps alive can't clear it. The media viewer README documents the components and adds a manual check.

Not included, possible follow-ups: Previous/Next track from the Lock Screen, an AirPlay button in the adaptive (folded) layout, and audio interruptions such as phone calls (#3671).

How to verify

  1. Open an audio file (ideally a tagged music file) and start playback.
  2. Lock the device: the Lock Screen shows the track with its artwork. Check Play/Pause, −10/+10 and scrubbing.
  3. Open Control Center: the Nextcloud player is present, and its AirPlay picker lists your receivers.
  4. In the app, tap the new AirPlay button at the top right of the audio screen and pick a receiver: playback moves to it.
  5. Close the viewer, or swipe to an image: the Lock Screen controls disappear.
  6. Repeat, auto-advance and video playback (AVPlayer and VLC) behave as before.

Unit tests: NCAudioNowPlayingTests (Swift Testing, no server needed).

Tested on: iPhone 12, iOS 26.7.3, Nextcloud 35.0.3, AirPlay to a Sonos Ray.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (Claude Code, claude-opus-5-5)

Audio from the media viewer keeps playing in the background, but it
never appeared on the Lock Screen or in Control Center, so it could not
be paused or skipped without unlocking the phone and reopening the app.
Without a Now Playing session the app was also missing from Control
Center's AirPlay picker, and the audio screen had no AirPlay button, so
music could not be sent to AirPlay speakers such as Sonos.

Only the audio page that started playing owns the Now Playing session,
because the viewer keeps the players of neighboring pages alive and
they must not clear it. The long-form audio route policy is what Apple
recommends for music and lets AirPlay 2 receivers buffer the stream.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon St-Michel <simonstmichel@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant