Skip to Content
Programming iOS 10
book

Programming iOS 10

by Matt Neuburg
November 2016
Beginner to intermediate content levelBeginner to intermediate
800 pages
30h 12m
English
O'Reilly Media, Inc.
Content preview from Programming iOS 10

Chapter 15. Video

Video playback is performed using classes such as AVPlayer provided by the AV Foundation framework (import AVFoundation). An AVPlayer is not a view; rather, an AVPlayer’s content is made visible through a CALayer subclass, AVPlayerLayer, which can be added to your app’s interface.

An AV Foundation video playback interface can be wrapped in a simple view controller, AVPlayerViewController (introduced in iOS 8): you provide an AVPlayer, and the AVPlayerViewController automatically hosts an associated AVPlayerLayer in its own main view, providing standard playback transport controls so that the user can start and stop play, seek to a different frame, and so forth. AVPlayerViewController is provided by the AVKit framework; you’ll need to import AVKit.

Note

AVPlayerViewController effectively supersedes the Media Player framework’s MPMoviePlayerController and MPMoviePlayerViewController, which were deprecated in iOS 9 and are not discussed in this edition.

A simple interface for letting the user trim video (UIVideoEditorController) is also supplied. Sophisticated video editing can be performed through the AV Foundation framework, as I’ll demonstrate later in this chapter.

If an AVPlayer produces sound, you may need to concern yourself with your application’s audio session; see Chapter 14. AVPlayer deals gracefully with the app being sent into the background: it will pause when your app is backgrounded and resume when your app returns to the foreground.

A movie file ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming iOS 12

Programming iOS 12

Matt Neuburg
Programming iOS 11

Programming iOS 11

Matt Neuburg
Programming iOS 13

Programming iOS 13

Matt Neuburg

Publisher Resources

ISBN: 9781491970157Errata Page