diff --git a/Source/Filters/Video/YPVideoFiltersVC.swift b/Source/Filters/Video/YPVideoFiltersVC.swift index d3c490025..b302b7224 100644 --- a/Source/Filters/Video/YPVideoFiltersVC.swift +++ b/Source/Filters/Video/YPVideoFiltersVC.swift @@ -93,7 +93,7 @@ public final class YPVideoFiltersVC: UIViewController, IsMediaFilterVC { .addObserver(self, selector: #selector(itemDidFinishPlaying(_:)), name: .AVPlayerItemDidPlayToEndTime, - object: nil) + object: videoView.player.currentItem) // Set initial video cover imageGenerator = AVAssetImageGenerator(asset: self.inputAsset) diff --git a/Source/Filters/Video/YPVideoView.swift b/Source/Filters/Video/YPVideoView.swift index 9b3779f6e..476f5aced 100644 --- a/Source/Filters/Video/YPVideoView.swift +++ b/Source/Filters/Video/YPVideoView.swift @@ -44,9 +44,6 @@ public class YPVideoView: UIView { singleTapGR.numberOfTapsRequired = 1 addGestureRecognizer(singleTapGR) - // Loop playback - addReachEndObserver() - playerView.alpha = 0 playImageView.alpha = 0.8 playerLayer.videoGravity = .resizeAspect @@ -153,13 +150,13 @@ extension YPVideoView { NotificationCenter.default.addObserver(self, selector: #selector(playerItemDidReachEnd(_:)), name: .AVPlayerItemDidPlayToEndTime, - object: nil) + object: player.currentItem) } /// Removes the observer for AVPlayerItemDidPlayToEndTime. Could be needed to implement own observer public func removeReachEndObserver() { NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, - object: nil) + object: player.currentItem) } }