Skip to content

feat(mobile): show viewed photo and video on AirPlay display - #33885

Open
sifferman wants to merge 11 commits into
immich-app:mainfrom
sifferman:feat-external-display-photo
Open

sifferman wants to merge 11 commits into
immich-app:mainfrom
sifferman:feat-external-display-photo

Conversation

@sifferman

Copy link
Copy Markdown
Contributor

Description

Hello! Thank you for this tool, and sorry for such a large PR. I noticed this issue when trying to Airplay photos for my family.

Resolves #23791 and #9267.

This makes Airplay in Immich behave like in iOS Photos. iOS gives every app a second window scene on an external display (AirPlay or cable), and an app that leaves it empty gets the mirror. This patch puts the media on that external display canvas. Here are the main changes:

  • the cast dialog gets one line on iOS pointing to Screen Mirroring in Control Center, since an app can't start mirroring itself
  • the open photo is drawn on the TV, fit to the screen. Until then the TV keeps mirroring
  • swipes and pinch zoom on the phone move the TV picture the same way
  • a video plays on the TV from the viewer's own AVPlayer, through a second AVPlayerLayer. The controls stay on the phone
  • closing the viewer leaves the photo up. A video keeps playing while the display is connected, loops if loop video is on, and reopening it picks up the same player

The scene connects differently per iOS version, and iOS 27 and iOS 15 each have their own commit. iOS 16 to 26 connect it from Info.plist. iOS 27 only connects it after the app registers a scene accessory. iOS 15 needs the older UIWindowSceneSessionRoleExternalDisplay role. Though I don't have hardware to test iOS 15, I just saw that requirement in Apple's docs. I can drop the untested iOS 15 commit if needed.

There's no in-app AirPlay button. I'm not sure how to do that. So I just wrote a message in the cast interface.

Feel free to look at the commit history. It shows the incremental features being added.

native_video_player

I created a fork of native_video_player to get videos playing properly: immich-app/native_video_player@main...sifferman:native_video_player:expose-playing-player. For now pubspec.yaml points at the fork so the branch builds, and that pin has to go back to immich-app before this merges. I can open a pull request if desired.

Each video commit here uses one commit from the fork:

Commit in this PR Commit in the fork What the fork commit adds
play viewed video on external display report the playing player to the host onPlay reports the AVPlayer when playback starts, so Immich can attach a second layer
keep closed video on external display let the host keep a closed player keepsPlayingAfterClose asks Immich whether a closing view should keep its player. A kept player still loops if setLoop(true) was set
resume closed video on reopen resume a kept player on reopen a new view loading the same source takes over the kept player, with no reload or seek

onPlay and keepsPlayingAfterClose are optional callbacks. An app that doesn't set them sees no change.

How Has This Been Tested?

  • iPhone 15 Pro (iOS 27.2.1) mirroring to an Apple TV 4K A1842 (tvOS 26.6.1). The TV mirrors until a photo opens, then shows the photo, follows zoom and swipes, plays video with sound, keeps a closed video playing, and resumes the same video on reopen.
  • iPhone 15 Pro (iOS 27.2.1) on a cable.
  • iOS 27.2 simulator (Xcode 27.2) with xcrun simctl io <device> screenConfig --display=external power on.
  • 10 new unit tests pass: flutter test test/unit/presentation/external_display_photo_test.dart test/unit/presentation/cast_dialog_test.dart
    • 3 for which image is sent to the display: the server preview, the on-device photo when the asset isn't uploaded, or nothing past either end of the timeline
    • 5 for converting the phone's zoom and pan for the display
    • 2 for the AirPlay hint in the cast dialog: shown on iOS, not on Android
  • iOS 15 to 25. Xcode 27.2 has no simulator older than iOS 26.

No unit tests cover the Swift side, because there's no iOS test target and CI never launches the app.

Screenshots (if appropriate)

immich-cast-dialog-airplay
demo-github.mp4

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

I used Claude to draft all changes and draft this description. However, I have thoroughly reviewed every line, and take full accountability for this PR.

@immich-push-o-matic

immich-push-o-matic Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Label error. Requires exactly 1 of: changelog:.*. Found: 📱mobile. A maintainer will add the required label.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant