Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transitioning AVplayer in modal transition

We are trying to achieve the same effect as within the Facebook app regarding tapping on a video in the feed and transitioning the same video at the same time to a modal view.

How do you transition an AVplayer from a uitableviewcell to a new instance of a uiviewcontroller seamlessly?

like image 339
cohen72 Avatar asked Feb 28 '16 08:02

cohen72


1 Answers

I achieved this by implemnting the UIViewControllerTransitioningDelegate and using my own custom animator object, which conforms to the UIViewControllerAnimatedTransitioning protocol.

I used https://github.com/recruit-mp/RMPZoomTransitionAnimator as a reference, with a few modifications to move an actual view (not a snapshot) between source and destination UIViewControllers :

Within the animator object, using the animator object's delegate methods for "source frame" and "destiation frame" and "playerView", all which are implemented on the "to" and "from" view controllers, I grab the view containing the playing video, grab it's start frame, it's end frame, and properly animate the view from its start frame to the frame it will end up being located at on the "to" view controller.

Upon completion of the transition, I then add the playing video UIView as a subview to the destination view controller, so that it becomes part of the "to" view controller's view, available for interacting with, etc.

like image 123
cohen72 Avatar answered Nov 16 '22 20:11

cohen72