avkit for tvos - devstreaming-cdn.apple.com · siri voice commands older apple tv remotes ios...

144
© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Interactive video playback Media #WWDC16 Session 506 AVKit for tvOS Dan Wright AVKit Engineer

Upload: vuongtruc

Post on 07-Apr-2019

239 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Interactive video playback

Media #WWDC16

Session 506

AVKit for tvOS

Dan Wright AVKit Engineer

Page 2: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Page 3: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surface

Page 4: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surfaceSiri voice commands

Page 5: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surfaceSiri voice commandsOlder Apple TV remotes

Page 6: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surfaceSiri voice commandsOlder Apple TV remotesiOS Remote app

Page 7: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surfaceSiri voice commandsOlder Apple TV remotesiOS Remote app Bluetooth keyboards

Page 8: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surfaceSiri voice commandsOlder Apple TV remotesiOS Remote app Bluetooth keyboardsGame controllers

Page 9: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Video Playback on Apple TV

Siri remote: Touch surfaceSiri voice commandsOlder Apple TV remotesiOS Remote app Bluetooth keyboardsGame controllersInfrared universal remotes

Page 10: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Modern playback with a consistent user experienceIntroducing AVKit for tvOS

Page 11: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

Page 12: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing video + transport bar (skipping)]

Page 13: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing video + transport bar (scanning)]

Page 14: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing video + transport bar (scrubbing)]

Page 15: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing Info panels (description panel)]

Page 16: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing Info panels (audio panel)]

Page 17: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

Siri…

“Go back to the beginning”

“Skip ahead 10 minutes”

“What did she say?”

“Switch to French”

Page 18: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Same on tvOS, iOS, and macOSModern Media Stack

Page 19: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Same on tvOS, iOS, and macOSModern Media Stack

AVKit

Page 20: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Same on tvOS, iOS, and macOSModern Media Stack

AVKit

AVFoundation

CoreMedia

Page 21: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Same on tvOS, iOS, and macOSModern Media Stack

AVKit

AVFoundation

CoreMedia

UIKit/AppKit

Page 22: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Agenda

Page 23: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Agenda

Getting Started with AVKit

Page 24: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Agenda

Getting Started with AVKitExtending Playback with Features Unique to tvOS

Page 25: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Agenda

Getting Started with AVKitExtending Playback with Features Unique to tvOSBest Practices

Page 26: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Getting Started with AVKit

Page 27: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

AVFoundation and AVKit basicsAVPlayerViewController

AVPlayerViewController

AVPlayer

AVPlayerItem

AVAsset

Page 28: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Steps to provide content for AVPlayerViewControllerProviding Content

Page 29: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Steps to provide content for AVPlayerViewControllerProviding Content

// 1. Create asset from a URL let asset = AVAsset(url: url)

Page 30: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Steps to provide content for AVPlayerViewControllerProviding Content

// 1. Create asset from a URL let asset = AVAsset(url: url)

// 2. Create a playerItem with the asset let playerItem = AVPlayerItem(asset: asset)

Page 31: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Steps to provide content for AVPlayerViewControllerProviding Content

// 1. Create asset from a URL let asset = AVAsset(url: url)

// 2. Create a playerItem with the asset let playerItem = AVPlayerItem(asset: asset)

// 3. Create a player with the playerItem let player = AVPlayer(playerItem: playerItem)

Page 32: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Steps to provide content for AVPlayerViewControllerProviding Content

// 1. Create asset from a URL let asset = AVAsset(url: url)

// 2. Create a playerItem with the asset let playerItem = AVPlayerItem(asset: asset)

// 3. Create a player with the playerItem let player = AVPlayer(playerItem: playerItem)

// 4. Associate player with player view controller playerViewController.player = player

Page 33: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

In one line of codeProviding Content

// All four steps in one line of code. playerViewController.player = AVPlayer(url: url)

Page 34: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For noninteractive playbackEmbedding an Inline Player

Page 35: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For noninteractive playbackEmbedding an Inline Player

// 1. Set up playerViewController let playerViewController = AVPlayerViewController() playerViewController.player = AVPlayer(url: url)

Page 36: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For noninteractive playbackEmbedding an Inline Player

// 1. Set up playerViewController let playerViewController = AVPlayerViewController() playerViewController.player = AVPlayer(url: url)

// 2. Set its frame to the inline view (use constraints!) playerViewController.view.frame = inlineVideoRect

Page 37: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For noninteractive playbackEmbedding an Inline Player

// 1. Set up playerViewController let playerViewController = AVPlayerViewController() playerViewController.player = AVPlayer(url: url)

// 2. Set its frame to the inline view (use constraints!) playerViewController.view.frame = inlineVideoRect

// 3. Add it to your view myViewController.view.addSubview(playerViewController.view) myViewController.addChildViewController(playerViewController)

Page 38: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For full-user interactionInteractive Full-Screen Presentation

// If the view was embedded, it will zoom automatically myViewController.present(playerViewController, animated:true, completion:nil)

Page 39: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Advanced features of AVKit on tvOSExtending the Playback Experience

Page 40: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Introduced in tvOS 9.0Extending the Playback Experience

Page 41: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Introduced in tvOS 9Extending the Playback Experience

Adding noninteractive overlays

Page 42: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Introduced in tvOS 9Extending the Playback Experience

Adding noninteractive overlaysRestricting playback interaction (requiresLinearPlayback)

Page 43: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Introduced in tvOS 9Extending the Playback Experience

Adding noninteractive overlaysRestricting playback interaction (requiresLinearPlayback)Providing informational metadata

Page 44: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Introduced in tvOS 9Extending the Playback Experience

Adding noninteractive overlaysRestricting playback interaction (requiresLinearPlayback)Providing informational metadataProviding navigation markers

Page 45: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Introduced in tvOS 9Extending the Playback Experience

Adding noninteractive overlaysRestricting playback interaction (requiresLinearPlayback)Providing informational metadataProviding navigation markersIdentifying interstitial content

Page 46: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

New in tvOS 10Extending the Playback Experience NEW

Page 47: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

New in tvOS 10Extending the Playback Experience

Changing skipping behavior

NEW

Page 48: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

New in tvOS 10Extending the Playback Experience

Changing skipping behaviorPresenting content proposals

NEW

Page 49: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For logos and other overlaid graphicsOverlays

The playback overlay view lies above the video, but below the controls

Page 50: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For logos and other overlaid graphicsOverlays

The playback overlay view lies above the video, but below the controls

Page 51: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For logos and other overlaid graphicsOverlays

The playback overlay view lies above the video, but below the controls

Logo

Video

Controls

Page 52: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For logos and other overlaid graphicsOverlays

The playback overlay view lies above the video, but below the controlsViews may be static or animated

Page 53: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For logos and other overlaid graphicsOverlays

The playback overlay view lies above the video, but below the controlsViews may be static or animatedViews will not receive focus/events

Page 54: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Restricting Playback

Restricting playback interaction (requiresLinearPlayback)User interaction is limited to play/pause • Fast-forward, scrubbing, and skipping are forbidden

Page 55: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

External Metadata

The externalMetadata property of AVPlayerItem supplements or replaces embedded information:• Title• Description• Genre (Drama, Comedy)• Media content rating• Poster artwork

Page 56: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

Page 57: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

Page 58: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating external metadata itemsExternal Metadata

func metadataItem(identifier : String, value : protocol<NSCopying, NSObjectProtocol>?) -> AVMetadataItem? { if let actualValue = value { let item = AVMutableMetadataItem() item.value = actualValue item.identifier = identifier item.extendedLanguageTag = "und" // undefined (wildcard) language return item.copy() as? AVMetadataItem } return nil }

Page 59: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating external artwork itemsExternal Metadata

func metadataArtworkItem(image: UIImage) -> AVMetadataItem? { let item = AVMutableMetadataItem() // Choose PNG or JPEG item.value = UIImagePNGRepresentation(image) item.dataType = kCMMetadataBaseDataType_PNG as String item.identifier = AVMetadataCommonIdentifierArtwork item.extendedLanguageTag = "und" return item.copy() as? AVMetadataItem }

Page 60: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating external artwork itemsExternal Metadata

var allItems : [AVMetadataItem] = []

allItems.append(metadataItem(identifier: AVMetadataCommonIdentifierTitle, value: "The Title”)!)

allItems.append(metadataItem(identifier: AVMetadataCommonIdentifierDescription, value: "Your description goes here.”)!)

if let artworkItem = metadataItem(posterImage) { allItems.append(artworkItem) }

allItems.append(metadataItem(identifier: AVMetadataIdentifierQuickTimeMetadataGenre, value: “Comedy”)!)

playerItem.externalMetadata = allItems

Page 61: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

Page 62: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

Page 63: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For chapters and eventsNavigation Marker Groups

Used for chapters or to identify interesting events• Events might include things such as scoring or game highlights

Viewers can easily navigate to markers

Page 64: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For easy navigation of chapters and eventsNavigation Marker Groups

Chapter 1

Chapter 2

Chapter 3

AVNavigationMarkersGroup

Page 65: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For easy navigation of chapters and eventsNavigation Marker Groups

Chapter 1

Chapter 2

Chapter 3

AVNavigationMarkersGroup

AVTimedMetadataGroups

Page 66: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Chapter 1

Chapter 2

Chapter 3

AVNavigationMarkersGroup

For easy navigation of chapters and eventsNavigation Marker Groups

Every marker has a title

Page 67: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

For easy navigation of chapters and eventsNavigation Marker Groups

Chapter 1

Chapter 2

Chapter 3

AVNavigationMarkersGroupAn event group has a title; a chapter group does not

Page 68: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating navigation markersNavigation Marker Groups

func navigationMarker(title : String, description : String, timeRange : CMTimeRange) -> AVTimedMetadataGroup { var items : [AVMetadataItem] = [] if let titleItem = metadataItem(identifier: AVMetadataCommonIdentifierTitle, value: title) { items.append(titleItem) } if let descriptionItem = metadataItem(identifier: AVMetadataCommonIdentifierDescription, value: description) { items.append(descriptionItem) } return AVTimedMetadataGroup(items: items, timeRange: timeRange) }

Page 69: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating navigation markersNavigation Marker Groups

func navigationMarker(title : String, description : String, timeRange : CMTimeRange) -> AVTimedMetadataGroup { var items : [AVMetadataItem] = [] if let titleItem = metadataItem(identifier: AVMetadataCommonIdentifierTitle, value: title) { items.append(titleItem) } if let descriptionItem = metadataItem(identifier: AVMetadataCommonIdentifierDescription, value: description) { items.append(descriptionItem) } return AVTimedMetadataGroup(items: items, timeRange: timeRange) }

Page 70: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating navigation markersNavigation Marker Groups

func navigationMarker(title : String, description : String, timeRange : CMTimeRange) -> AVTimedMetadataGroup { var items : [AVMetadataItem] = [] if let titleItem = metadataItem(identifier: AVMetadataCommonIdentifierTitle, value: title) { items.append(titleItem) } if let descriptionItem = metadataItem(identifier: AVMetadataCommonIdentifierDescription, value: description) { items.append(descriptionItem) } return AVTimedMetadataGroup(items: items, timeRange: timeRange) }

Page 71: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating navigation markersNavigation Marker Groups

func navigationMarker(title : String, description : String, timeRange : CMTimeRange) -> AVTimedMetadataGroup { var items : [AVMetadataItem] = [] if let titleItem = metadataItem(identifier: AVMetadataCommonIdentifierTitle, value: title) { items.append(titleItem) } if let descriptionItem = metadataItem(identifier: AVMetadataCommonIdentifierDescription, value: description) { items.append(descriptionItem) } return AVTimedMetadataGroup(items: items, timeRange: timeRange) }

Page 72: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing interstitial playing]

Page 73: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing interstitial playing]

Page 74: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing interstitial playing]

Page 75: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Collapsing content unrelated to the main videoInterstitial Content

Page 76: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Collapsing content unrelated to the main videoInterstitial Content

Typically unrelated to the main media

Page 77: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Collapsing content unrelated to the main videoInterstitial Content

Typically unrelated to the main mediaAn interstitial time range identifies a portion of an asset

Page 78: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Collapsing content unrelated to the main videoInterstitial Content

Typically unrelated to the main mediaAn interstitial time range identifies a portion of an assetInterstitial time ranges collapse into dots on the transport bar

Page 79: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Collapsing content unrelated to the main videoInterstitial Content

Typically unrelated to the main mediaAn interstitial time range identifies a portion of an assetInterstitial time ranges collapse into dots on the transport barDuring scrubbing, interstitial content is hidden

Page 80: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Identifying the asset time rangesInterstitials

30 sec 60 sec 9:00

7:30

Asset

Transport bar

Page 81: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Identifying the asset time rangesInterstitials

Interstitials

30 sec 60 sec 9:00

7:30

Asset

Transport bar

Page 82: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating and declaringInterstitial Content

Page 83: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating and declaringInterstitial Content

Interstitial content should be stitched into your asset on your server (HLS)

Page 84: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating and declaringInterstitial Content

Interstitial content should be stitched into your asset on your server (HLS)Declare interstitial time ranges

Page 85: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating and declaringInterstitial Content

Interstitial content should be stitched into your asset on your server (HLS)Declare interstitial time rangesImplement delegate methods to enforce playback policy

Page 86: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Declaring interstitial time rangesInterstitial Content

var interstitialTimeRanges = [AVInterstitialTimeRange]()

let start = CMTime(seconds: startInterval, preferredTimescale: 1000) let duration = CMTime(seconds: durationInterval, preferredTimescale: 1000)

let interstitialTimeRange = AVInterstitialTimeRange(timeRange: CMTimeRange(start: start, duration: duration))

interstitialTimeRanges.append(interstitialTimeRange)

myPlayerItem.interstitialTimeRanges = interstitialTimeRanges

Page 87: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

func playerViewController(playerViewController: AVPlayerViewController, willPresent interstitial: AVInterstitialTimeRange){ // Prevent user navigation inside interstitials playerViewController.requiresLinearPlayback = true }

Page 88: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

func playerViewController(playerViewController: AVPlayerViewController, willPresent interstitial: AVInterstitialTimeRange){ // Prevent user navigation inside interstitials playerViewController.requiresLinearPlayback = true } func playerViewController(playerViewController: AVPlayerViewController, didPresent interstitial: AVInterstitialTimeRange) { // Allow user navigation outside interstitials playerViewController.requiresLinearPlayback = false }

Page 89: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

func playerViewController(playerViewController: AVPlayerViewController, willPresent interstitial: AVInterstitialTimeRange){ // Prevent user navigation inside interstitials playerViewController.requiresLinearPlayback = true } func playerViewController(playerViewController: AVPlayerViewController, didPresent interstitial: AVInterstitialTimeRange) { // Allow user navigation outside interstitials playerViewController.requiresLinearPlayback = false } func playerViewController(playerViewController: AVPlayerViewController, timeToSeekAfterUserNavigatedFrom oldTime: CMTime, to targetTime: CMTime) -> CMTime { // Alter this time to redirect to an interstitial let interstitialStartTime = startTimeOfSkippedInterstice(oldTime, to: targetTime) return interstitialStartTime.isValid ? interstitialStartTime : targetTime }

Page 90: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 7921408 x 792

NEW

Page 91: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

NEW

Page 92: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

NEW

1408 x 792

Page 93: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Modifying the actions associated with skippingSkipping Behavior

public enum AVPlayerViewControllerSkippingBehavior : Int {

case `default`

case skipItem

}

extension AVPlayerViewController {

public var skippingBehavior: AVPlayerViewControllerSkippingBehavior

public var isSkipForwardEnabled: Bool

public var isSkipBackwardEnabled: Bool

}

NEW

Page 94: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Modifying the actions associated with skippingSkipping Behavior

// Skip by-item instead of skip +/- a few seconds playerViewController.skippingBehavior = .skipItem playerViewController.isSkipForwardEnabled = true playerViewController.isSkipBackwardEnabled = true

// Delegate methods respond to skipping by-item func skipToNextItem(for playerViewController: AVPlayerViewController) { let nextPlayerItem = AVPlayerItem(url: nextUrl) playerViewController.player?.replaceCurrentItem(nextPlayerItem) } func skipToPreviousItem(for playerViewController: AVPlayerViewController) { playerViewController.player?.replaceCurrentItem(AVPlayerItem(url:prevUrl)) }

NEW

Page 95: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Modifying the actions associated with skippingSkipping Behavior

// Skip by-item instead of skip +/- a few seconds playerViewController.skippingBehavior = .skipItem playerViewController.isSkipForwardEnabled = true playerViewController.isSkipBackwardEnabled = true

// Delegate methods respond to skipping by-item func skipToNextItem(for playerViewController: AVPlayerViewController) { let nextPlayerItem = AVPlayerItem(url: nextUrl) playerViewController.player?.replaceCurrentItem(nextPlayerItem) } func skipToPreviousItem(for playerViewController: AVPlayerViewController) { playerViewController.player?.replaceCurrentItem(AVPlayerItem(url:prevUrl)) }

NEW

Page 96: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Modifying the actions associated with skippingSkipping Behavior

// Skip by-item instead of skip +/- a few seconds playerViewController.skippingBehavior = .skipItem playerViewController.isSkipForwardEnabled = true playerViewController.isSkipBackwardEnabled = true

// Delegate methods respond to skipping by-item func skipToNextItem(for playerViewController: AVPlayerViewController) { let nextPlayerItem = AVPlayerItem(url: nextUrl) playerViewController.player?.replaceCurrentItem(nextPlayerItem) } func skipToPreviousItem(for playerViewController: AVPlayerViewController) { playerViewController.player?.replaceCurrentItem(AVPlayerItem(url:prevUrl)) }

NEW

Page 97: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Modifying the actions associated with skippingSkipping Behavior

// Skip by-item instead of skip +/- a few seconds playerViewController.skippingBehavior = .skipItem playerViewController.isSkipForwardEnabled = true playerViewController.isSkipBackwardEnabled = true

// Delegate methods respond to skipping by-item func skipToNextItem(for playerViewController: AVPlayerViewController) { let nextPlayerItem = AVPlayerItem(url: nextUrl) playerViewController.player?.replaceCurrentItem(nextPlayerItem) } func skipToPreviousItem(for playerViewController: AVPlayerViewController) { playerViewController.player?.replaceCurrentItem(AVPlayerItem(url:prevUrl)) }

NEW

Page 98: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

DemoBasic playback with AVKit

Jonathan Long AVKit Engineer

Page 99: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals NEW

Page 100: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing (custom) content proposal presentation]

NEW

Page 101: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

NEW

Page 102: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

NEW

CurrentVideo

Page 103: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing (custom) content proposal presentation]

NEW

Page 104: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

1408 x 792

[Screenshot showing (custom) content proposal presentation]

NEW

Proposed Video

Page 105: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public class AVContentProposal : NSObject, NSCopying {

public var contentTimeForTransition: CMTime { get }

public var automaticAcceptanceInterval: TimeInterval

public var title: String { get }

public var previewImage: UIImage? { get }

public var url: URL?

public var metadata: [AVMetadataItem]

public init(contentTimeForTransition: CMTime, title: String, previewImage: UIImage?)

}

extension AVPlayerItem {

public var nextContentProposal: AVContentProposal?

}

NEW

Page 106: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public class AVContentProposal : NSObject, NSCopying {

public var contentTimeForTransition: CMTime { get }

public var automaticAcceptanceInterval: TimeInterval

public var title: String { get }

public var previewImage: UIImage? { get }

public var url: URL?

public var metadata: [AVMetadataItem]

public init(contentTimeForTransition: CMTime, title: String, previewImage: UIImage?)

}

extension AVPlayerItem {

public var nextContentProposal: AVContentProposal?

}

NEW

Page 107: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public class AVContentProposal : NSObject, NSCopying {

public var contentTimeForTransition: CMTime { get }

public var automaticAcceptanceInterval: TimeInterval

public var title: String { get }

public var previewImage: UIImage? { get }

public var url: URL?

public var metadata: [AVMetadataItem]

public init(contentTimeForTransition: CMTime, title: String, previewImage: UIImage?)

}

extension AVPlayerItem {

public var nextContentProposal: AVContentProposal?

}

NEW

Page 108: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public class AVContentProposal : NSObject, NSCopying {

public var contentTimeForTransition: CMTime { get }

public var automaticAcceptanceInterval: TimeInterval

public var title: String { get }

public var previewImage: UIImage? { get }

public var url: URL?

public var metadata: [AVMetadataItem]

public init(contentTimeForTransition: CMTime, title: String, previewImage: UIImage?)

}

extension AVPlayerItem {

public var nextContentProposal: AVContentProposal?

}

NEW

Page 109: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public class AVContentProposal : NSObject, NSCopying {

public var contentTimeForTransition: CMTime { get }

public var automaticAcceptanceInterval: TimeInterval

public var title: String { get }

public var previewImage: UIImage? { get }

public var url: URL?

public var metadata: [AVMetadataItem]

public init(contentTimeForTransition: CMTime, title: String, previewImage: UIImage?)

}

extension AVPlayerItem {

public var nextContentProposal: AVContentProposal?

}

NEW

Page 110: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating the content proposalContent Proposals

// Create the proposal

NEW

Page 111: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating the content proposalContent Proposals

// Create the proposal let contentProposal = AVContentProposal(contentTimeForTransition: kCMTimeZero, title: "Happy Hijinks S9 E2", previewImage: previewImage)

NEW

Page 112: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating the content proposalContent Proposals

// Create the proposal let contentProposal = AVContentProposal(contentTimeForTransition: kCMTimeZero, title: "Happy Hijinks S9 E2", previewImage: previewImage) contentProposal.url = urlForHappyHijinksS9E2

NEW

Page 113: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Creating the content proposalContent Proposals

// Create the proposal let contentProposal = AVContentProposal(contentTimeForTransition: kCMTimeZero, title: "Happy Hijinks S9 E2", previewImage: previewImage) contentProposal.url = urlForHappyHijinksS9E2

// Now assign the proposal to the player item which should show the proposal playerItemForHappyHijinksS9E1.nextContentProposal = contentProposal

NEW

Page 114: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public protocol AVContentProposalDelegate {

optional public func playerViewController(playerViewController: AVPlayerViewController,

shouldPresent proposal: AVContentProposal) -> Bool

optional public func playerViewController(playerViewController: AVPlayerViewController,

didAccept proposal: AVContentProposal)

optional public func playerViewController(playerViewController: AVPlayerViewController,

didReject proposal: AVContentProposal)

}

NEW

Page 115: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public protocol AVContentProposalDelegate {

optional public func playerViewController(playerViewController: AVPlayerViewController,

shouldPresent proposal: AVContentProposal) -> Bool

optional public func playerViewController(playerViewController: AVPlayerViewController,

didAccept proposal: AVContentProposal)

optional public func playerViewController(playerViewController: AVPlayerViewController,

didReject proposal: AVContentProposal)

}

NEW

Page 116: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public protocol AVContentProposalDelegate {

optional public func playerViewController(playerViewController: AVPlayerViewController,

shouldPresent proposal: AVContentProposal) -> Bool

optional public func playerViewController(playerViewController: AVPlayerViewController,

didAccept proposal: AVContentProposal)

optional public func playerViewController(playerViewController: AVPlayerViewController,

didReject proposal: AVContentProposal)

}

NEW

Page 117: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Suggesting what to watch nextContent Proposals

public protocol AVContentProposalDelegate {

optional public func playerViewController(playerViewController: AVPlayerViewController,

shouldPresent proposal: AVContentProposal) -> Bool

optional public func playerViewController(playerViewController: AVPlayerViewController,

didAccept proposal: AVContentProposal)

optional public func playerViewController(playerViewController: AVPlayerViewController,

didReject proposal: AVContentProposal)

}

NEW

Page 118: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Custom presentationsContent Proposals

public class AVContentProposalViewController : UIViewController {

public var contentProposal: AVContentProposal? { get }

weak public var playerViewController: AVPlayerViewController? { get }

public var preferredPlayerViewFrame: CGRect { get }

public var playerLayoutGuide: UILayoutGuide { get }

public var dateOfAutomaticAcceptance: Date?

public func dismissContentProposal(for action: AVContentProposalAction, animated: Bool,

completion block: (() -> Void)? = nil)

}

NEW

Page 119: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Custom presentationsContent Proposals

public class AVContentProposalViewController : UIViewController {

public var contentProposal: AVContentProposal? { get }

weak public var playerViewController: AVPlayerViewController? { get }

public var preferredPlayerViewFrame: CGRect { get }

public var playerLayoutGuide: UILayoutGuide { get }

public var dateOfAutomaticAcceptance: Date?

public func dismissContentProposal(for action: AVContentProposalAction, animated: Bool,

completion block: (() -> Void)? = nil)

}

NEW

Page 120: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Custom presentationsContent Proposals

public class AVContentProposalViewController : UIViewController {

public var contentProposal: AVContentProposal? { get }

weak public var playerViewController: AVPlayerViewController? { get }

public var preferredPlayerViewFrame: CGRect { get }

public var playerLayoutGuide: UILayoutGuide { get }

public var dateOfAutomaticAcceptance: Date?

public func dismissContentProposal(for action: AVContentProposalAction, animated: Bool,

completion block: (() -> Void)? = nil)

}

NEW

Page 121: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Responding to delegate notificationsContent Proposals

func playerViewController(playerViewController: AVPlayerViewController, shouldPresent proposal: AVContentProposal) -> Bool {

// Set up a custom presentation just-in-time playerViewController.contentProposalViewController = MyContentProposalViewController() return true }

NEW

Page 122: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Responding to delegate notificationsContent Proposals

func playerViewController(playerViewController: AVPlayerViewController, didAccept proposal: AVContentProposal) { // Replace the current AVPlayerItem with the proposed content guard let player = playerViewController.player, let url = proposal.url else { return } player.replaceCurrentItem(AVPlayerItem(url: url)) }

NEW

Page 123: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

DemoContent Proposals

Jonathan Long AVKit Engineer

Page 124: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

with AVKit on tvOSBest Practices

Page 125: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Page 126: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Let present handle zooming from inline player views

Page 127: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Let present handle zooming from inline player viewsPlayback is only interactive when full-screen

Page 128: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Let present handle zooming from inline player viewsPlayback is only interactive when full-screenUse the new content proposal API

Page 129: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Let present handle zooming from inline player viewsPlayback is only interactive when full-screenUse the new content proposal APIObserve the player/player item error property

Page 130: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Avoid toggling showsPlaybackControls

Page 131: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Avoid toggling showsPlaybackControlsAvoid adding supplemental gestures to playback

Page 132: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Avoid toggling showsPlaybackControlsAvoid adding supplemental gestures to playbackDo not overload the Select button or touch surface gestures

Page 133: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Replace your asset upon AVErrorMediaServicesWereReset

Page 134: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

With AVKit on tvOSBest Practices

Replace your asset upon AVErrorMediaServicesWereReset Other sessions with best practices for playback:

Advances in AVFoundation Playback Mission Wednesday 9:00AM

Mastering Modern Media Playback WWDC 2014

Page 135: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Summary

Page 136: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Summary

Standard playback controls and behaviors

Page 137: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Summary

Standard playback controls and behaviorsSupport for remotes, game controllers, and Siri

Page 138: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Summary

Standard playback controls and behaviorsSupport for remotes, game controllers, and SiriFull access to media stack

Page 139: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Summary

Standard playback controls and behaviorsSupport for remotes, game controllers, and SiriFull access to media stackPowerful new APIs

Page 140: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Summary

Standard playback controls and behaviorsSupport for remotes, game controllers, and SiriFull access to media stackPowerful new APIs Easy to get started

Page 141: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

More Information

https://developer.apple.com/wwdc16/506

Page 142: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Related Sessions

Advances in AVFoundation Playback Mission Wednesday 9:00AM

What’s New in HTTP Live Streaming Mission Wednesday 3:00PM

Developing tvOS Apps Using TVMLKit: Part 1 Mission Wednesday 1:40PM

Developing tvOS Apps Using TVMLKit: Part 2 Nob Hill Thursday 4:00PM

Mastering Modern Media Playback WWDC 2014

Page 143: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster

Lab

AVKit Lab Graphics, Games, and Media Lab C Friday 1:00PM

Page 144: AVKit for tvOS - devstreaming-cdn.apple.com · Siri voice commands Older Apple TV remotes iOS Remote app Bluetooth keyboards Game controllers Infrared universal remotes. ... • Poster