我有一個Swift應用程序。我想通過使用moviePlayer播放一些視頻。我正在使用下面的代碼。視頻拉伸問題iOS Swift
let url = NSURL.fileURLWithPath(path)
moviePlayer = MPMoviePlayerController(contentURL: url)
// moviePlayer?.controlStyle = .None
if let player = moviePlayer {
player.view.frame = CGRect(x: 20, y: 165, width: widthVideoView, height: heightVideoView)
player.prepareToPlay()
player.scalingMode = .AspectFill
self.view.addSubview(player.view)
}
播放視頻沒問題。但現在我的視頻被拉長了。我認爲這是因爲
player.scalingMode = .AspectFill
所以我改變
player.scalingMode = .AspectFit
然後我的屏幕就像這樣(用黑色屏幕頂部底部。)我如何處理這個問題。
您試圖實現的是什麼? – Armin
看看我的第一個截圖視頻拉伸了嗎?在我的第二個地方有黑色的空間。我希望像第一個一樣全尺寸的視頻,而不是拉伸。 – Amsheer
試試這個player.view.frame = CGRect(x:0,y:0,width:widthVideoView,height:heightVideoView)和layer.scalingMode = .AspectFit –