简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM