/duology-recipes:recipe-media-playerfrom duology-recipes
Creates a complete SwiftUI video and podcast player for iPhone Duo (Apple's foldable) from scratch. Covers library list-detail, full-screen player surviving folds, tabletop/book layouts, Picture in Picture, up next card, mini player, and background audio.
Ships in duology-recipes. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This recipe makes a new Xcode project: a video podcast app for iPhone Duo. The library lists shows and episodes. An episode plays full screen. Close the phone, open it, fold it like a book or set it on a table half folded, and the video keeps playing from the same frame. Near the end of an episode, an "up next" card offers the next one.
The shows are sample content. The value is the frame around them: one player that no layout change can restart, one set of controls that moves to the right place in every pose, rules you can test on the Mac in seconds, and UI tests that pass on the Duo simulator.
Labels: measured means we ran it on the iPhone Duo simulator (iOS 27.1, 20 October 2026). Unverified means we could not check it. Everything else links to Apple. "Book" and "tabletop" are Duology's words for Apple's "partially folded, like a book" and "seated on a table like a laptop"; no API reports them. Full source list: reference/sources.md.
Use a different skill when:
duo-postures (its tabletop media recipe) and duo-continuity (playback through a fold);recipe-reader./duo-new recipe-media-player runs steps 1 to 5. Run every step yourself when there is no command.
Get three values from the user, or propose them:
AppName: letters and digits, starting with a letter (it becomes a Swift type, <AppName>App). Not Tools, and not an Apple module name such as SwiftUI or AVFoundation;com.example.fieldcast;Run the script from this skill's folder (in the plugin: ${CLAUDE_PLUGIN_ROOT}/skills/recipe-media-player/scripts/new-project.sh):
"${CLAUDE_PLUGIN_ROOT}/skills/recipe-media-player/scripts/new-project.sh" \
FieldCast com.example.fieldcast ~/Developer/FieldCast
It copies template/, replaces __APP_NAME__ and __BUNDLE_ID__ in file contents and paths (the video clips are left alone), checks none are left, and prints the next steps. It refuses a folder that exists and is not empty (exit 73), and bad or clashing names (exit 65), before it creates anything.
Test the rules on the Mac. Expect 0 failed:
cd ~/Developer/FieldCast && Tools/run-model-tests.sh
Build for the Duo simulator (find its UDID with xcrun simctl list devices available | grep "iPhone Duo"):
DEVELOPER_DIR=/Applications/Xcode-27.1.app/Contents/Developer \
xcodebuild -project FieldCast.xcodeproj -scheme FieldCast \
-destination "platform=iOS Simulator,id=<UDID>" \
-derivedDataPath build/DerivedData build
Install, launch straight into the player, and screenshot the display in use. Use the UDID, not booted.
DEV=/Applications/Xcode-27.1.app/Contents/Developer
DEVELOPER_DIR=$DEV xcrun simctl install <UDID> build/DerivedData/Build/Products/Debug-iphonesimulator/FieldCast.app
DEVELOPER_DIR=$DEV xcrun simctl launch --terminate-running-process <UDID> com.example.fieldcast -play small-repairs-1 -paused -start 4
DEVELOPER_DIR=$DEV xcrun simctl io <UDID> screenshot --display=primary build/outer.png # closed
DEVELOPER_DIR=$DEV xcrun simctl io <UDID> screenshot --display=primary-1 build/inner.png # open
Only the display in use has content. Look at the PNG before you report.
Run the UI tests: DESTINATION="id=<UDID>" Tools/run-ui-tests.sh. A UI test brings the app to the front; tell the user first if they share the simulator.
Tell the user what passed, and that poses change only in Device Hub (the checklist below).
Set DEVELOPER_DIR for every xcrun and xcodebuild call when the Mac has more than one Xcode. Never run xcode-select.
| Path | What it holds |
|---|---|
<App>/Model/ | Catalogue, queue, up next policy, resume points, fold geometry, player regions, time text. Foundation and CoreGraphics only, every type nonisolated and Sendable. |
<App>/Player/PlayerModel.swift | @Observable owner of the one AVPlayer, its AVPlayerLayer and the Picture in Picture controller. Time observer, end of episode, background audio, saving. |
<App>/Player/PlayerScreen.swift, PlayerControls.swift | The player: FoldRegionsLayout with the video first and the controls second; the up next card inside the controls. |
<App>/Player/VideoSurface.swift | A UIViewRepresentable that shows the model's layer and never makes its own; the AirPlay button. |
<App>/Library/ | NavigationSplitView of shows and episodes, the episode detail, the mini player, drawn artwork. |
<App>/Shared/ | FoldRegionsLayout, onFoldChange, test markers. |
<App>/Media/ | Catalog.json and six 12-second clips, 640 × 360, about 110 KB each. |
<App>/Info.plist | Only UIBackgroundModes = audio; Xcode generates the rest. |
<App>UITests/ | Twelve UI tests, pose-agnostic. |
Tools/ | run-model-tests.sh, ModelTests/main.swift, run-ui-tests.sh. |
Project settings: iOS 26.0 deployment, Swift 6 language mode, SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor, approachable concurrency, file-system synchronized groups with one exception (Info.plist is not a resource), iPhone and iPad, a privacy manifest that declares UserDefaults (reason CA92.1) for resume points. The scheme turns off parallel testing so xcodebuild doesn't clone the simulator.
Architecture, data flow and test details: references/architecture.md. Sample clips, streams, Picture in Picture and background audio: references/media.md.
| Pose | Library | Player | Up next card | Mini player |
|---|---|---|---|---|
| Closed (outer display) | Collapsed to one stack; side bars | Controls float at the bottom; the video moves up into the space above them | Inside the controls, button on its own row | Full width, bottom |
| Open, flat, held wide | Sidebar and detail | Controls float over the video, bottom centre | Inside the controls | Trailing side of the fold line |
| Book | The system evens the columns out at the fold | Video in the leading region, controls in the trailing region | Trailing, with the controls | Trailing region |
| Tabletop | Detail, sidebar behind its button | Video above the fold, the same controls below it | Below the fold | Full width, bottom region |
Measured for the player and the library in every row, with Device Hub's pose buttons pressed by duo-pose, and with one app process kept through closed, open, book, tabletop and closed again.
| Technique | Where | Why |
|---|---|---|
| Playback survives every fold | PlayerModel is @State in RootView; the player screen is a fullScreenCover attached there | State below a layout switch is rebuilt; state above it isn't (duo-continuity). RootView never changes identity. |
| The video layer is never rebuilt | PlayerModel.playerLayer; VideoSurface only hosts it | A new layer would flash black. The surfaces test marker counts views made: measured 1 through a full pose sweep. |
| One layout for every pose | FoldRegionsLayout in PlayerScreen, geometry in Model/FoldRegions.swift | One Layout type, so both children keep their identity (Layout). An if on the fold would rebuild them. |
| Reading the fold | onFoldChange on the layout itself; FoldGeometry(candidates:in:) | reservedRegions(kind:options:layoutDirectionBehavior:) with .division and .includeInactive, read in onGeometryChange because the first layout pass has no regions. There is no posture API (api-index). |
| Tabletop: watch above, touch below | FoldRegions.split | Apple's one optional per-pose layout: media in the top half, the same controls in the bottom half (talk 111466). |
| Nothing interactive in the fold | The up next card lives inside PlayerControls | It moves with the controls, so it is never on the fold's 40 pt frame. |
| The mini player avoids the fold | FoldRegions.floatingBarSpan | A bar across the open phone would put its buttons on the fold line. It reads the fold even while flat, so folding doesn't move it. |
| Library keeps its selection | LibraryModel.selection, one NavigationSplitView | The split view collapses closed and evens out at the fold on its own (NavigationSplitView). Never swap it for a stack by size class. |
| Picture in Picture | PlayerModel creates AVPictureInPictureController from its own layer | The system pins the floating video to the top, and stretches it to half the screen when the phone is partly folded; the app below must cope with a shorter window (talk 111466). |
| Sound in the background | sceneMovedToBackground(_:), Info.plist, the playback category | iOS pauses a video whose layer is on screen; the model takes the player off its layer in the background (media playback setup). |
| No autoplay on fold, no pause on fold | Nothing in the views starts or stops playback | Folding is not a request to play. No onAppear or onDisappear touches the player. |
| Screen stays on only while watching | RootView | isIdleTimerDisabled follows "playing and on screen". |
Change the catalogue and the rules first, then the look.
Media/Catalog.json. media is a bundled file name or an https URL (an HLS playlist works the same way). Run Tools/run-model-tests.sh: it checks every bundled file exists, IDs are unique and episodes are numbered.UpNextPolicy.lead (default 10 s, never more than half an episode) and autoplay. The library's options menu has the autoplay switch.PlayerControls (the glass panel), Artwork (swap for AsyncImage when you have image URLs), EpisodeDetailView.Artwork in VideoFrame instead of the surface. Code: references/media.md.Model/, keep it nonisolated and Sendable, add a check in Tools/ModelTests/main.swift and a line to its off-main-actor check.Keep these, whatever the app:
AVPlayer, one AVPlayerLayer, one Picture in Picture controller, owned by a model above every layout switch.FoldRegionsLayout for the player: video first, controls second. Never an if on the pose.onAppear, onDisappear or .task below the root.IconButton).On the Mac: Tools/run-model-tests.sh builds Model/*.swift with the test program using swiftc -swift-version 6 -default-isolation MainActor, like the app target. It reads the real Catalog.json and checks each clip. The fold checks use the frames measured on the Duo simulator (book: a 40 × 669 pt fold at x 455 in 951 × 669 pt; tabletop: 669 × 40 pt at y 455). Measured: 103 checks, under 10 seconds with the build.
On the simulator: Tools/run-ui-tests.sh. The tests start from launch switches (-play, -paused, -start, -select, -upNextLead, -autoplay 0, -loop, -resetState), find elements by identifier, tap through element.coordinate(withNormalizedOffset:), and read the player through the player.state marker (item=…|playing=1|time=4|upNext=counting|pip=0|surfaces=1|presented=1|). They never depend on the pose. Tests that need time start paused or stop at the end instead of racing a 12-second clip.
Measured: 11 passed and 1 skipped on the closed Duo simulator, about 140 s of tests; testPlayerLayoutInThisPose also passed in book pose and in tabletop. Picture in Picture is not supported on the iPhone Duo simulator (isPictureInPictureSupported() returned false), so the player hides its button there and testPictureInPictureStarts skips. Check Picture in Picture on a device.
Then check each pose by hand in Device Hub, or with duo-pose-matrix (needs the user's Accessibility permission):
duo-pose-matrix com.example.fieldcast \
--case "library=-resetState -select small-repairs-2" \
--case "player=-resetState -play small-repairs-1 -paused -start 4"
To see playback survive the poses, launch with -play night-sky-notes-1 -loop and pass --no-relaunch.
scripts/new-project.sh; no __APP_NAME__ or __BUNDLE_ID__ left.Tools/run-model-tests.sh prints 0 failed.xcodebuild … build succeeds for the iPhone Duo simulator with no warnings from your code.Tools/run-ui-tests.sh passes (Picture in Picture skips on the simulator).references/architecture.md (opens in a new tab)references/media.md (opens in a new tab)scripts/make-sample-clips.sh (opens in a new tab)scripts/new-project.sh (opens in a new tab)template/README.md (opens in a new tab)template/Tools/ModelTests/main.swift (opens in a new tab)template/Tools/run-model-tests.sh (opens in a new tab)template/Tools/run-ui-tests.sh (opens in a new tab)template/__APP_NAME__.xcodeproj/project.pbxproj (opens in a new tab)template/__APP_NAME__.xcodeproj/project.xcworkspace/contents.xcworkspacedata (opens in a new tab)template/__APP_NAME__.xcodeproj/xcshareddata/xcschemes/__APP_NAME__.xcscheme (opens in a new tab)template/__APP_NAME__/App/LaunchOptions.swift (opens in a new tab)template/__APP_NAME__/App/RootView.swift (opens in a new tab)template/__APP_NAME__/App/__APP_NAME__App.swift (opens in a new tab)template/__APP_NAME__/Assets.xcassets/AccentColor.colorset/Contents.json (opens in a new tab)template/__APP_NAME__/Assets.xcassets/AppIcon.appiconset/AppIcon.png (opens in a new tab)template/__APP_NAME__/Assets.xcassets/AppIcon.appiconset/Contents.json (opens in a new tab)template/__APP_NAME__/Assets.xcassets/Contents.json (opens in a new tab)template/__APP_NAME__/Info.plist (opens in a new tab)template/__APP_NAME__/Library/Artwork.swift (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
swiftui, iphone-duo, video-player, podcast-player, foldable, avplayer
npx claudepluginhub kimeur/duology --plugin duology-recipes8 skills in this plugin
/recipe-camera-studioCreates a complete SwiftUI camera studio for iPhone Duo, Apple's foldable: photos and videos with the rear camera and a self-timer, and, while the phone is open, the person being filmed sees themselves on the outer display (CameraCaptureAccessory) with the countdown or the recording time. Closed or open and flat, the controls float along the bottom or trailing edge, off the fold; folded like a book, the preview takes the left page and the controls the right; in tabletop the preview sits above the fold and the controls below it. Use when someone wants to start a new camera, photo booth, self-portrait or filming app from scratch, or runs /duo-new recipe-camera-studio. Covers AVFoundation capture on an actor (photo and movie outputs, rotation coordinators, a second mirrored preview layer), a stand-in camera that makes the simulator usable (it has no camera), an in-app gallery with ShareLink and no file dates, usage strings, a privacy manifest with Mac checks, and UI tests on the iPhone Duo simulator./recipe-finance-dashboardCreates a complete SwiftUI personal finance dashboard for iPhone Duo, Apple's foldable: balance and recent spending in one column on the closed outer display; balance, a Swift Charts spending chart and the transaction list side by side on the open inner display; an even 8-column grid with the fold as its middle gutter (DuoColumns and PaneFrames from duo-design-system); and list-detail for a transaction that survives fold and unfold. Use when someone wants to start a new finance, budgeting, banking, expenses or any dashboard app from scratch (a new Xcode project), or runs /duo-new recipe-finance-dashboard. For an existing app, use duo-design-system (grid) and duo-patterns (list-detail) instead. Covers FoldPanes reading the .division reserved region with includeInactive, one NavigationStack whose path comes from the selection, a delayed pop on unfold that keeps the margins right, money as whole cents, a Foundation-only model tested on the Mac, and UI tests that pass in any pose on the iPhone Duo simulator./recipe-kids-learningCreates a complete SwiftUI early-learning app for young children on iPhone Duo, Apple's foldable: counting, first letters and shapes, one question at a time with a spoken prompt and big answer buttons. Closed, the picture sits above the answers; open and held wide or folded like a book, the question takes the left page and the answers the right; in tabletop the picture sits above the fold and the answers below it. Use when someone wants to start a new kids, preschool or early-learning quiz app from scratch, or runs /duo-new recipe-kids-learning. Covers a parental gate (a seeded multiplication on a number pad) in front of a grown-ups area with reset and the privacy policy link, App Review guidelines 1.3 and 5.1.4 for the Kids Category, a privacy manifest with no tracking and no data collected, no networking with a Mac check that fails if it appears, AVSpeechSynthesizer prompts, VoiceOver, progress that survives folds and relaunch, a model tested on the Mac, and UI tests on the iPhone Duo simulator./recipe-notes-aiCreates a complete SwiftUI notes app for iPhone Duo, Apple's foldable, with summaries from Apple's on-device model (Foundation Models): a headline, key points and to-dos per note, streamed in. Closed, the note fills the screen and the summary is one line with Details; open, flat or like a book, the note takes the left page and the summary pane the right; in tabletop the note sits above the fold and the summary below it. Use when someone wants to start a new notes, journal or writing app with AI summaries from scratch, or runs /duo-new recipe-notes-ai. Covers a @Generable result streamed into a window-owned service so a fold never restarts it, a simple summary without AI whenever the model is unavailable or fails (it fails on the simulator), Stop and labels that say what is AI, a prompt budget for the 4,096-token context, notes that never leave the device (no network, no Private Cloud Compute) with a privacy manifest and Mac checks that say so, and UI tests on the iPhone Duo simulator./recipe-readerCreates a complete SwiftUI reading app for iPhone Duo, Apple's foldable: a library shelf, then one page on the closed outer display, two facing pages split at the fold when the phone is open and held wide or folded like a book, and in tabletop the page above the fold with the page turns below it. Use when someone wants to start a new e-reader, book, story, essay or long-form reading app from scratch, or runs /duo-new recipe-reader. For an existing reader, use duo-reading instead. Covers the reading place kept as a chapter and character offset in a store above the navigation stack, TextKit 1 pagination that runs again after every fold, rotation and Dynamic Type change, ReaderLayout reading the .division reserved region, an even-column shelf split at the fold, an in-app text size menu, swipe and VoiceOver page turns, three sample books written for the template, a Foundation-only model tested on the Mac (the paginator too, through AppKit), and UI tests that work on the iPhone Duo simulator./recipe-shopCreates a complete SwiftUI shop for iPhone Duo, Apple's foldable, that sells digital packs and a subscription with StoreKit 2: a product grid with even columns that reflows from 2 per row on the closed outer display to 4 on the open inner display with the fold as its middle gutter, product detail beside the grid when open, a basket that checks out one App Store purchase at a time, and a two-pane paywall and checkout (what you get on one side, price and button on the other; one column with the button pinned when closed). Use when someone wants to start a new shop, catalog, in-app purchase or paywall app from scratch, or runs /duo-new recipe-shop. For an existing app, use duo-patterns (feed reflow, list-detail) instead. Covers a local StoreKit configuration file (no network, no real products), PurchaseAction, Transaction.updates and currentEntitlements, restore, Ask to Buy, SKTestSession in UI tests, a Foundation-only model tested on the Mac, and UI tests that pass in any pose on the iPhone Duo simulator.Other plugins' skills for the same job