18.1 · AVPlayer, time, and editing with compositions

AVFoundation is the engine behind every Apple video and audio app. Its mental model is small: assets describe media, items carry playback state, a player plays them, and time is a rational number, not a float.

Mental model. Media is asynchronous and stateful. Nothing is ready until you are told, and time is exact only if you keep it as a fraction.

Playing media

Player, item, asset, status, buffering and time.

  1. How do AVAsset, AVPlayerItem and AVPlayer fit together, what is CMTime, and why does playback “not start”? 18.1.1 · L3
    Three objects and a clock. An AVAsset (AVURLAsset) is the static description of media: its tracks, duration, metadata; it loads properties asynchronously (try…

Editing media

Compositions, tracks and time ranges.

  1. How do AVMutableComposition, tracks and time ranges work for editing, and how do you export the result? 18.1.2 · L5
    An AVMutableComposition is an AVAsset you build in code by stitching segments of other assets on a timeline, without copying any media: it only records which…

More in Media & graphics