diff options
author | marinofaggiana <marino@marinofaggiana.com> | 2021-01-14 13:51:26 +0300 |
---|---|---|
committer | marinofaggiana <marino@marinofaggiana.com> | 2021-01-14 13:51:26 +0300 |
commit | cd60a37f9d88159db22285747575408cf1a34c23 (patch) | |
tree | ed16416d04b78a3bde68472f4cdd8129ca163b81 /iOSClient/Viewer | |
parent | 95cd19223c19067d5071f82fa64be48ef6e532b9 (diff) |
fix
Diffstat (limited to 'iOSClient/Viewer')
-rw-r--r-- | iOSClient/Viewer/NCViewerProviderContextMenu.swift | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/iOSClient/Viewer/NCViewerProviderContextMenu.swift b/iOSClient/Viewer/NCViewerProviderContextMenu.swift index 3a000e940..29e50be62 100644 --- a/iOSClient/Viewer/NCViewerProviderContextMenu.swift +++ b/iOSClient/Viewer/NCViewerProviderContextMenu.swift @@ -27,11 +27,19 @@ import NCCommunication class NCViewerProviderContextMenu: UIViewController { private let imageView = UIImageView() + private var videoLayer: AVPlayerLayer? override func loadView() { view = imageView } + override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + if let videoLayer = self.videoLayer { + videoLayer.frame = imageView.layer.bounds + } + } + init(metadata: tableMetadata) { super.init(nibName: nil, bundle: nil) @@ -98,14 +106,14 @@ class NCViewerProviderContextMenu: UIViewController { } let player = AVPlayer(url: URL(fileURLWithPath: filePath)) - let videoLayer = AVPlayerLayer(player: player) - videoLayer.frame = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height) - videoLayer.videoGravity = AVLayerVideoGravity.resize - - imageView.frame = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height) - imageView.layer.addSublayer(videoLayer) - + self.videoLayer = AVPlayerLayer(player: player) + if let videoLayer = self.videoLayer { + videoLayer.videoGravity = .resizeAspectFill + imageView.frame = CGRect(x: 0, y: 0, width: newSize.width, height: newSize.height) + imageView.layer.addSublayer(videoLayer) + } + player.isMuted = true player.play() } |