This is my code that changes the view size on orientation change so that the video will always fill the entire screen and overflow
Code: Select all
func adaptMovieFrameToScreen() {
let screen = UIScreen.screens[0].bounds
let videoSize = self.mediaPlayer.videoSize
let ratio = videoSize.width / videoSize.height
let screenRatio = screen.width / screen.height
var size = CGSize()
if videoSize.width == 0 || videoSize.height == 0 {
return
}
size.height = screen.height
size.width = size.height * videoSize.width / videoSize.height
if ratio < screenRatio {
size.width = screen.width
size.height = size.width / ratio
}
self.movieView.frame = CGRect(origin: UIScreen.screens[0].bounds.origin, size: size)
self.scrollView.frame = self.movieView.frame
debugPrint("Video Size: \(videoSize), Ratio: \(ratio)")
debugPrint("Debug Frame Size: \(size), Ratio: \(screenRatio)")
debugPrint("Debug Movie Frame Size \(movieView.frame.size)")
debugPrint("Debug Screen Size \(screen.size)")
resetZoom()
}
sorry but pasting the log here was puttin me over character limit