2021 SwiftUI & UI FrameworksAudio & Video
WWDC21 · 11 min · SwiftUI & UI Frameworks / Audio & Video
Deliver a great playback experience on tvOS
Find out how you can use Apple TV’s redesigned playback interface to build great media experiences in your apps. Learn how the latest interface helps people access relevant controls and information while maintaining focus on content. We’ll show you how you can adopt AVPlayerViewController and other APIs for your tvOS app to help people find, play, and enjoy content. To get the most out of this session, we recommend having a basic understanding of AVKit.
Watch at developer.apple.com ↗Code shown on screen · 4 snippets
Transport Bar Controls Example
let favoriteAction = UIAction(title: "Favorites", image: UIImage(systemName: "heart")) {
// Add to favorites
}
let submenu = UIMenu(title: "Speed", options: [.displayInline, .singleSelection],
children: [ UIAction(…) ])
let menu = UIMenu(image: UIImage(systemName: "gearshape"), children: [submenu, UIAction(…)])
playerViewController.transportBarCustomMenuItems = [favoriteAction, menu] Content Tabs Example
// Initialize content tab view controller
customViewController.preferredContentSize = CGSize(width: 0, height: 140)
customViewController.title = "Recommended" TVMediaItemContentConfiguration Example
// Configure 16:9 UICollectionView cell
import TVUIKit
var contentConfiguration = TVMediaItemContentConfiguration.wideCell()
contentConfiguration.image = UIImage(imageLiteralResourceName: "tanu")
contentConfiguration.text = "Title"
contentConfiguration.secondaryText = "Secondary text"
contentConfiguration.badgeText = "NEW"
contentConfiguration.badgeProperties.backgroundColor = .systemRed
contentConfiguration.playbackProgress = 0.75
cell.contentConfiguration = contentConfiguration TVMonogramContentConfiguration Example
// Configure monogram UICollectionView cell
import TVUIKit
var contentConfiguration = TVMonogramContentConfiguration.cell()
contentConfiguration.image = UIImage(imageLiteralResourceName: "jad")
contentConfiguration.text = "Jad"
cell.contentConfiguration = contentConfiguration Resources
Related sessions
-
8 min -
30 min -
19 min -
50 min -
40 min