Connecting Outlets
In fact, our player is so successful, there’s no way to actually stop it in the app. Click the Stop button on the Xcode toolbar to kill the app.
Let’s make our button both a Play and Pause button. To do that, we should only play if the player isn’t already playing. If it is playing, we need to pause.
A look at the AVPlayer documentation shows us the two pieces of information we need to make this work. First, in the “Managing Playback” section, right after play, there’s a pause method. And just after that, there’s rate, a Float that indicates how fast the media is playing, where 0.0 is paused and 1.0 is normal speed forward. This also means if we wanted to provide the popular “play podcast at one-and-a-half speed” feature, ...
Get iOS 10 SDK Development, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.