duo-media
Video and audio playback on iPhone Duo, Apple's foldable. Use when an app plays video or audio and must keep playing through fold, unfold and rotation, when you build a tabletop player (video above the fold, the same controls below) or a book-pose player, an up next queue, Picture in Picture, Now Playing or background audio. Covers one AVPlayer owned above the layout switch (VideoPlayer, AVPlayerViewController, AVPlayerLayer), ArrangementView with .overlay and overlayArrangementZIndex for up next (measured on the simulator in every pose), when to pick .split instead, toolbarVerticalBehavior(.disabled) for a full-screen player, AVPictureInPictureController and canStartPictureInPictureAutomaticallyFromInline, the pinned Picture in Picture video that takes half the screen when folded, MPNowPlayingSession and remote commands, the .playback audio session, and what to test in Device Hub and on a device.
Kimeur · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Kimeur/duology --skill duo-media技能说明
name: duo-media description: "Video and audio playback on iPhone Duo, Apple's foldable. Use when an app plays video or audio and must keep playing through fold, unfold and rotation, when you build a tabletop player (video above the fold, the same controls below) or a book-pose player, an up next queue, Picture in Picture, Now Playing or background audio. Covers one AVPlayer owned above the layout switch (VideoPlayer, AVPlayerViewController, AVPlayerLayer), ArrangementView with .overlay and overlayArrangementZIndex for up next (measured on the simulator in every pose), when to pick .split instead, toolbarVerticalBehavior(.disabled) for a full-screen player, AVPictureInPictureController and canStartPictureInPictureAutomaticallyFromInline, the pinned Picture in Picture video that takes half the screen when folded, MPNowPlayingSession and remote commands, the .playback audio session, and what to test in Device Hub and on a device." metadata: verified: "Xcode 27.1 (27A9275), iOS 27.1 simulator, device: no" sources: "https://github.com/Kimeur/duology/blob/main/reference/sources.md"
duo-media
People open, close and fold iPhone Duo while something plays. The video must not stop, restart or flash, and the controls must land where hands can reach them in every pose. This skill covers players, the tabletop layout, "up next", Picture in Picture, Now Playing and the audio session.
Load neighbours when the task needs them: duo-continuity (where state lives, for every kind of state), duo-postures (every pose, and the tabletop recipe with FoldRegionsLayout), duo-layout (ArrangementView in depth), duo-scenes (Split View and windows), duo-camera (capture).
"Tabletop" and "book" are Duology's words for what Apple describes as the phone seated on a table like a laptop, and partly folded like a book. Neither is an API. Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1); derived means reasoning from Apple's words or our measurements; unverified means we could not check it. Full source list: reference/sources.md.
Rules
- One
AVPlayerper window, in a model owned above every layout switch. Views only show it. - Never pause, reload or reset playback because of a fold, a resize or
onDisappear. - Start with the system player. Use your own controls when you want them below the fold in tabletop, and then bring back what the system player gave you.
- Tabletop: the video in the top region, the same controls in the bottom region. Book: the video leading, the controls trailing. No control exists only when folded.
- "Up next" that floats over the video: an overlay arrangement. "Up next" that must never be covered: a split.
- Support Picture in Picture. Expect your window to get shorter when a video is pinned on top, and shorter still when the phone is partly folded.
- Own the audio session and Now Playing in the model, not in views.
- A full-screen player turns the vertical bar off with
toolbarVerticalBehavior(.disabled), as a fixed choice for that screen. - Folding is not a request to play. Never start playback because the phone folded or opened.
1. One player above the layout switch
A fold resizes the window, often changes its size class, and rebuilds the views below a layout switch. A player created in one of those views starts again from zero (Tech Talk 111461, duo-continuity).
import AVKit
import SwiftUI
// requires: PlaybackModel (references/player-ownership.md)
struct PlayerRoot: View {
@State private var playback = PlaybackModel() // the window root owns the player
var body: some View {
VideoPlayer(player: playback.player) // a view of the player, nothing more
.ignoresSafeArea()
}
}
PlaybackModelholds the player, the queue, Picture in Picture and Now Playing. Itsplay(_:)ignores the item already playing, so a view that calls it again after a fold restarts nothing.AVPlayeris main-actor isolated in the iOS 27.1 SDK (AVPlayer.h), so the model is@MainActor.- Measured (20 Oct 2026): a model-owned player kept playing through book, tabletop and closing, and its
AVPlayerLayerview was created once.duo-continuitymeasured the same withVideoPlayerrebuilt on each flip.
The model, the root, what to avoid, and UIKit: references/player-ownership.md.
2. System player or your own controls
System player (AVPlayerViewController, VideoPlayer) | Your controls on an AVPlayerLayer | |
|---|---|---|
| Controls | Drawn over the video | Wherever you put them, below the fold included |
| Picture in Picture | AVPlayerViewController: built in once the audio session and background mode are set. Apple's guides don't cover VideoPlayer. | AVPictureInPictureController |
| Now Playing | AVPlayerViewController updates it by default | MPNowPlayingSession from your model |
| Captions, AirPlay | In the system controls | Yours to add (AVRoutePickerView for AirPlay) |
| Apple's advice | Prefer it (HIG: Playing video) | Match the system player's behaviour if you build one |
On Duo the difference is tabletop. The system player draws its controls over the video; Apple's tabletop advice wants them on the bottom half. Whether the system player moves them when the phone is partly folded is not measured yet (references/testing.md).
3. Tabletop and book
Apple names one optional layout for a single pose: the phone on a table, media in the top region, tappable controls on the stable bottom region, with the same controls and hierarchy as every other pose (Tech Talk 111466, [Tech Tal
阅读完整来源 ↗