Reputation: 11
I have a video player, that plays video url's parsed from json file. Everything works fine, except there is no smooth transition between the videos. I made the back-ground black (as recommended in one of the stack answers) but still don't like the short flash in-between.
Is there a way to fix this with a fade-in / fade - out for swift? I tried to implement AVQueuePlayer but I don't understand how to implement it in my code and don't understand how it works.
Please if any one knows a solution for smooth transition that would be great. The same questions asked on stack are either never answered or contain really old answers/solutions.
EDIT: My video is being played through the AVPlayerViewController. The video URL is for a mp4 video.
Upvotes: 1
Views: 1583
Reputation: 19884
You can fade out the player view, change the video, and then fade in the player view.
UIView.animate(withDuration: 0.1, animations: {
self.playerView.alpha = 0
}, completion: { _ in
self.playerView.loadUrl...// Update video
UIView.animate(withDuration: 0.1) {
self.playerView.alpha = 1
}
})
Upvotes: 1