Apologies
You must be signed in to watch this lesson.
Maximizing and Minimizing Player Animations
Podcasts
Quite common with many Audio Player apps is the ability to minimize the detailed episode view, allowing users access to browse for other interesting items in your app. In this lesson, we'll go over the basics of animating between two different anchors for our PlayerDetailsView object. In order to get this to work correctly, we first need to establish where are the maximized top and minimized top anchors. We'll be writing the implementation in MainTabBarController since we need access to the tabBar property. Enjoy.

Comments (3)
mohit1007
5 years ago
Hi brian, Question.. I just tried to run the project so far in actual ios device. For some reason, I can't hear the audio on device even though I can see that the stream is playing. In the simulator everything works fine. I was wondering if this is expected at this point on time or did I missed something? Thanks
mohit1007
5 years ago
Ok.. I followed the advice here: https://stackoverflow.com/questions/47788568/avplayer-is-unable-to-play-sound-in-device and after calling the function in episode didSet method (in PlayerDetailsView), it seems to be working. but I am curious if this is a hack or is that the right place to add this method
Brian Voong
5 years ago
Brian Voong
5 years ago
mohit1007
5 years ago
Ah awesome.. thanks for clarification.. I should stick to the pace of course rather getting ahead of myself. Thanks
Nicholas Culpin
5 years ago
Hey Brian, Thoughts on accessibility with this? Voice over seems to read elements behind the expanded player view after its displayed. Is there an easy way to disable accessibility elements based on the draw layer? Thanks for the course!
Nicholas Culpin
5 years ago
ended up using a simple notification, but if you have a better idea I'd be happy hear it!
Pavlos Nicolaou
4 years ago
I used 'accessibilityViewIsModal = true' In PlayerDetailsView initializer (when the player opens up) Here's more info: https://developer.apple.com/documentation/objectivec/nsobject/1615089-accessibilityviewismodal
Pavlos Nicolaou
4 years ago
Does anyone have the same problems with the Xcode11? The MainTabBar and MiniPlayer are pushed up when I minimized the Player! Thank you :)
AhmedSeddek
4 years ago
yes me too , u need to move this line self.view.layoutIfNeeded() to the end of the block of animation in minizePlayerDetails function and minizePlayerDetails function in MainTabBarController.swift file that will solve the pushing up when press Dismiss button but there is still small glitch of tabbar , if u solved it tell me pls .
AhmedSeddek
4 years ago
minizePlayerDetails and maximizePlayerDetails functions
ZeroSingularity
4 years ago
The problem arrises when calling layoutIfNeeded() before you call .identity on the tabBar transform. @objc func minimizePlayerDetails() { // the order of these calls prevents layout warnings maximizedTopAnchorConstraint.isActive = false bottomAnchorConstraint.constant = view.frame.height minimizedTopAnchorConstraint.isActive = true UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseOut, animations: { self.tabBar.transform = .identity self.view.layoutIfNeeded() self.playerDetailsView.maximizedStackView.alpha = 0 self.playerDetailsView.miniPlayerView.alpha = 1 }) }
HELP & SUPPORT