← chapterscript.com

Embedding ChapterPlayer

ChapterPlayer is a Swift package that runs ChapterScript documents on Apple Vision Pro. It bundles the sequence engine, spatial audio and video managers, entity factory, gate detection, and live-development client, so your app ships its UI, its content, and its product-specific extensions, and nothing else.

Installing

// Package.swift
.package(url: "https://github.com/mike-bundy/ChapterPlayer.git", branch: "main")

ChapterPlayer tracks the ChapterScript format package at main while the wire format is pre-1.0; both will pin to tagged versions once the format settles. A local sibling checkout of ChapterScript overrides the remote by package identity, the standard local-override workflow.

Requirements

What's inside

PieceWhat it does
SequenceEngineThe declarative sequence/step choreographer. Always resets entities on sequence change; pluggable executor protocols for entity, audio, video, attachment, and effect actions.
GateDetectionControllerHolds a step until its gate resolves (tap, gaze, approach, grab, or timeout), behind the GateDetecting protocol.
SpatialAudioManagerAVAudioEngine-based channel system with audio buses, ducking rules, audio zones, and loop configs.
VideoPlaybackManagerPer-channel AVPlayer orchestrator: flat scene panels, attachment-based SwiftUI overlays, and 360°/180° immersive skybox playback.
EntityFactoryBuilds RealityKit entities from ChapterScript definitions: primitives, USDZ models, 3D text, lights, and video panels, with a registry for app-specific custom factories.
DocumentEntityLoaderMaterializes a document's entities into the immersive scene and registers them with the executors.
BackdropCueDriverDrives sequence backdrop presentation (video and image skyboxes, full USDZ backdrop scenes) behind BackdropCuePresenting.
MotionCurveEvaluatorA thin delegate over ChapterScript's canonical curve sampling, so playback matches editor previews and motion trails exactly.
PulseRingEntity / SparkBurstEntityProcedural VFX primitives fired by the corresponding step actions.
AssetPreloaderWarms media before playback so first frames land on time.

Loading content

Content arrives through an ExperienceProvider paired with a MediaResolver:

What your app provides

The runtime is deliberately tool-agnostic: any document that decodes as valid ChapterScript plays, no matter what wrote it.