Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2022 Health & FitnessAudio & Video

WWDC22 · 24 min · Health & Fitness / Audio & Video

Create a great video playback experience

Find out how you can use the latest iOS and iPadOS system media players to build amazing media apps. We’ll share how we designed the updated player and give you best practices and tips to help you design media experiences of your own. We’ll also explore Live Text for video and show you how to integrate interstitials and playback speed controls into your apps.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 4 snippets

Setting content external metadata swift · at 4:08 ↗
// Setting content external metadata

let titleItem = AVMutableMetadataItem()
titleItem.identifier = .commonIdentifierTitle
titleItem.value = // Title string

let subtitleItem = AVMutableMetadataItem()
subtitleItem.identifier = .iTunesMetadataTrackSubTitle
subtitleItem.value = // Subtitle string

let infoItem = AVMutableMetadataItem()
infoItem.identifier = .commonIdentifierDescription
infoItem.value = // Descriptive info paragraph

playerItem.externalMetadata = [titleItem, subtitleItem, infoItem]
Creating a skip button for a preroll ad swift · at 19:03 ↗
// Creating a skip button for a preroll ad

let eventController = AVPlayerInterstitialEventController(primaryPlayer: mediaPlayer)

let event = AVPlayerInterstitialEvent(primaryItem: interstitialItem, time: .zero)
event.restrictions = [
	.requiresPlaybackAtPreferredRateForAdvancement,
	.constrainsSeekingForwardInPrimaryContent
]

eventController.events.append(event)


func playerViewController(playerViewController: AVPlayerViewController, willPresent interstitial: AVInterstitialTimeRange) {
	showSkipButton(afterTime: 5.0, onPress: {
		eventController.cancelCurrentEvent(withResumptionOffset: CMTime.zero)
	})
}
Setting custom playback speeds swift · at 21:14 ↗
// Setting custom playback speeds


let player = AVPlayerViewController()
player.player = // Some AVPlayer

present(player, animated: true)


let newSpeed = AVPlaybackSpeed(rate: 2.5, localizedName: "Two and a half times speed”)

player.speeds.append(newSpeed)
Hiding the playback speed menu swift · at 23:02 ↗
// Hiding the playback speed menu


let player = AVPlayerViewController()
player.player = // Some AVPlayer

present(player, animated: true)


player.speeds = []

Resources