Closed alimirshad closed 5 years ago
Hello @RuiAAPeres
Can you help me on this.
Fixed..
ItemBaseController.swift
`override open func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
scrollView.frame = self.view.bounds
activityIndicatorView.center = view.boundsCenter
//this is added
if let itemView = itemView as? VideoView{
itemView.frame = self.view.frame
itemView.center = scrollView.boundsCenter
}
else{
if let size = itemView.image?.size , size != CGSize.zero {
let aspectFitItemSize = aspectFitSize(forContentOfSize: size, inBounds: self.scrollView.bounds.size)
itemView.bounds.size = aspectFitItemSize
scrollView.contentSize = itemView.bounds.size
itemView.center = scrollView.boundsCenter
}
}
//end here
// if let size = itemView.image?.size , size != CGSize.zero {
//
// let aspectFitItemSize = aspectFitSize(forContentOfSize: size, inBounds: self.scrollView.bounds.size)
//
// itemView.bounds.size = aspectFitItemSize
// scrollView.contentSize = itemView.bounds.size
//
// itemView.center = scrollView.boundsCenter
// }
}`
VideoView.swift
`var player: AVPlayer? {
willSet {
if newValue == nil {
player?.removeObserver(self, forKeyPath: "status")
player?.removeObserver(self, forKeyPath: "rate")
}
}
didSet {
if let player = self.player,
let videoLayer = self.layer as? AVPlayerLayer {
videoLayer.player = player
//videoLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
videoLayer.videoGravity = AVLayerVideoGravity.resizeAspect
player.addObserver(self, forKeyPath: "status", options: NSKeyValueObservingOptions.new, context: nil)
player.addObserver(self, forKeyPath: "rate", options: NSKeyValueObservingOptions.new, context: nil)
}
}
}`
You should also change to previewImageView.contentMode = .scaleAspectFit in VideoView.swift init. Because then you can properly display vertical and horizontal video preview images.
Hello,
I am using this pod in my app. The video is square and getting cropped to 16:9. Because of this the video is getting cropped from the top. How to solve this.
In my app
ORIGINAL