NCViewerMedia.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. //
  2. // NCViewerMedia.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 24/10/2020.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. import SVGKit
  25. import NextcloudKit
  26. import EasyTipView
  27. import SwiftUI
  28. class NCViewerMedia: UIViewController {
  29. @IBOutlet weak var detailViewTopConstraint: NSLayoutConstraint!
  30. @IBOutlet weak var detailViewHeighConstraint: NSLayoutConstraint!
  31. @IBOutlet weak var imageViewTopConstraint: NSLayoutConstraint!
  32. @IBOutlet weak var imageViewBottomConstraint: NSLayoutConstraint!
  33. @IBOutlet weak var scrollView: UIScrollView!
  34. @IBOutlet weak var imageVideoContainer: imageVideoContainerView!
  35. @IBOutlet weak var statusViewImage: UIImageView!
  36. @IBOutlet weak var statusLabel: UILabel!
  37. @IBOutlet weak var detailView: NCViewerMediaDetailView!
  38. private var _autoPlay: Bool = false
  39. private var tipView: EasyTipView?
  40. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  41. weak var viewerMediaPage: NCViewerMediaPage?
  42. var playerToolBar: NCPlayerToolBar?
  43. var ncplayer: NCPlayer?
  44. var image: UIImage?
  45. var metadata: tableMetadata = tableMetadata()
  46. var index: Int = 0
  47. var doubleTapGestureRecognizer: UITapGestureRecognizer = UITapGestureRecognizer()
  48. var imageViewConstraint: CGFloat = 0
  49. var isDetailViewInitializze: Bool = false
  50. var autoPlay: Bool {
  51. get {
  52. let temp = _autoPlay
  53. _autoPlay = false
  54. return temp
  55. }
  56. set(newVal) {
  57. _autoPlay = newVal
  58. }
  59. }
  60. // MARK: - View Life Cycle
  61. required init?(coder aDecoder: NSCoder) {
  62. super.init(coder: aDecoder)
  63. doubleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didDoubleTapWith(gestureRecognizer:)))
  64. doubleTapGestureRecognizer.numberOfTapsRequired = 2
  65. }
  66. deinit {
  67. print("deinit NCViewerMedia")
  68. self.tipView?.dismiss()
  69. NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
  70. }
  71. override func viewDidLoad() {
  72. super.viewDidLoad()
  73. scrollView.delegate = self
  74. scrollView.maximumZoomScale = 4
  75. scrollView.minimumZoomScale = 1
  76. view.addGestureRecognizer(doubleTapGestureRecognizer)
  77. if NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) != nil {
  78. statusViewImage.image = NCUtility.shared.loadImage(named: "livephoto", color: .gray)
  79. statusLabel.text = "LIVE"
  80. } else {
  81. statusViewImage.image = nil
  82. statusLabel.text = ""
  83. }
  84. if metadata.classFile == NKCommon.TypeClassFile.video.rawValue || metadata.classFile == NKCommon.TypeClassFile.audio.rawValue {
  85. playerToolBar = Bundle.main.loadNibNamed("NCPlayerToolBar", owner: self, options: nil)?.first as? NCPlayerToolBar
  86. if let playerToolBar = playerToolBar {
  87. view.addSubview(playerToolBar)
  88. playerToolBar.translatesAutoresizingMaskIntoConstraints = false
  89. playerToolBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
  90. playerToolBar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: 0).isActive = true
  91. playerToolBar.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 0).isActive = true
  92. playerToolBar.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: 0).isActive = true
  93. playerToolBar.viewerMediaPage = viewerMediaPage
  94. }
  95. self.ncplayer = NCPlayer.init(autoPlay: self.autoPlay, imageVideoContainer: self.imageVideoContainer, playerToolBar: self.playerToolBar, metadata: self.metadata, detailView: self.detailView, viewController: self)
  96. }
  97. // TIP
  98. var preferences = EasyTipView.Preferences()
  99. preferences.drawing.foregroundColor = .white
  100. preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
  101. preferences.drawing.textAlignment = .left
  102. preferences.drawing.arrowPosition = .top
  103. preferences.drawing.cornerRadius = 10
  104. preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
  105. preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
  106. preferences.animating.showInitialAlpha = 0
  107. preferences.animating.showDuration = 0.5
  108. preferences.animating.dismissDuration = 0
  109. tipView = EasyTipView(text: NSLocalizedString("_tip_open_mediadetail_", comment: ""), preferences: preferences, delegate: self)
  110. detailViewTopConstraint.constant = 0
  111. detailView.hide()
  112. self.image = nil
  113. self.imageVideoContainer.image = nil
  114. reloadImage()
  115. }
  116. override func viewWillAppear(_ animated: Bool) {
  117. super.viewWillAppear(animated)
  118. viewerMediaPage?.navigationController?.navigationBar.prefersLargeTitles = false
  119. viewerMediaPage?.navigationItem.title = metadata.fileNameView
  120. if metadata.classFile == NKCommon.TypeClassFile.image.rawValue, let viewerMediaPage = self.viewerMediaPage {
  121. viewerMediaPage.currentScreenMode = viewerMediaPage.saveScreenModeImage
  122. if viewerMediaPage.modifiedOcId.contains(metadata.ocId) {
  123. viewerMediaPage.modifiedOcId.removeAll(where: { $0 == metadata.ocId })
  124. reloadImage()
  125. }
  126. }
  127. if viewerMediaPage?.currentScreenMode == .full {
  128. viewerMediaPage?.navigationController?.setNavigationBarHidden(true, animated: true)
  129. NCUtility.shared.colorNavigationController(viewerMediaPage?.navigationController, backgroundColor: .black, titleColor: .white, tintColor: nil, withoutShadow: false)
  130. viewerMediaPage?.view.backgroundColor = .black
  131. viewerMediaPage?.textColor = .white
  132. viewerMediaPage?.progressView.isHidden = true
  133. } else {
  134. viewerMediaPage?.navigationController?.setNavigationBarHidden(false, animated: true)
  135. NCUtility.shared.colorNavigationController(viewerMediaPage?.navigationController, backgroundColor: .systemBackground, titleColor: .label, tintColor: nil, withoutShadow: false)
  136. viewerMediaPage?.view.backgroundColor = .systemBackground
  137. viewerMediaPage?.textColor = .label
  138. viewerMediaPage?.progressView.isHidden = false
  139. }
  140. }
  141. override func viewDidAppear(_ animated: Bool) {
  142. super.viewDidAppear(animated)
  143. if metadata.classFile == NKCommon.TypeClassFile.video.rawValue || metadata.classFile == NKCommon.TypeClassFile.audio.rawValue {
  144. if let ncplayer = self.ncplayer {
  145. NCNetworking.shared.getVideoUrl(metadata: metadata) { url in
  146. if let url = url {
  147. ncplayer.openAVPlayer(url: url)
  148. self.viewerMediaPage?.updateCommandCenter(ncplayer: ncplayer, metadata: self.metadata)
  149. }
  150. }
  151. }
  152. } else if metadata.classFile == NKCommon.TypeClassFile.image.rawValue {
  153. viewerMediaPage?.clearCommandCenter()
  154. }
  155. showTip()
  156. NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
  157. }
  158. override func viewWillDisappear(_ animated: Bool) {
  159. super.viewWillDisappear(animated)
  160. self.tipView?.dismiss()
  161. }
  162. override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
  163. super.viewWillTransition(to: size, with: coordinator)
  164. self.tipView?.dismiss()
  165. coordinator.animate(alongsideTransition: { context in
  166. // back to the original size
  167. self.scrollView.zoom(to: CGRect(x: 0, y: 0, width: self.scrollView.bounds.width, height: self.scrollView.bounds.height), animated: false)
  168. self.view.layoutIfNeeded()
  169. UIView.animate(withDuration: context.transitionDuration) {
  170. if self.detailView.isShow() {
  171. self.openDetail()
  172. }
  173. }
  174. }, completion: { context in
  175. self.showTip()
  176. })
  177. }
  178. // MARK: - Tip
  179. func showTip() {
  180. if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerMediaDetailView), let view = self.navigationController?.navigationBar {
  181. self.tipView?.show(forView: view)
  182. }
  183. }
  184. // MARK: - Image
  185. func reloadImage() {
  186. if let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) {
  187. self.metadata = metadata
  188. loadImage(metadata: metadata)
  189. }
  190. }
  191. func loadImage(metadata: tableMetadata) {
  192. // Download image
  193. if !CCUtility.fileProviderStorageExists(metadata) && metadata.classFile == NKCommon.TypeClassFile.image.rawValue && metadata.session == "" {
  194. if metadata.livePhoto {
  195. let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
  196. if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !CCUtility.fileProviderStorageExists(metadata) {
  197. NCNetworking.shared.download(metadata: metadata, selector: "") { _, _ in }
  198. }
  199. }
  200. NCNetworking.shared.download(metadata: metadata, selector: "") { _, _ in
  201. let image = getImageMetadata(metadata)
  202. if self.metadata.ocId == metadata.ocId && self.imageVideoContainer.layer.sublayers?.count == nil {
  203. self.image = image
  204. self.imageVideoContainer.image = image
  205. }
  206. }
  207. }
  208. // Get image
  209. let image = getImageMetadata(metadata)
  210. if self.metadata.ocId == metadata.ocId && self.imageVideoContainer.layer.sublayers?.count == nil {
  211. self.image = image
  212. self.imageVideoContainer.image = image
  213. }
  214. func getImageMetadata(_ metadata: tableMetadata) -> UIImage? {
  215. if let image = getImage(metadata: metadata) {
  216. return image
  217. }
  218. if metadata.classFile == NKCommon.TypeClassFile.video.rawValue && !metadata.hasPreview {
  219. NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  220. }
  221. if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) {
  222. if let imagePreviewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) {
  223. return UIImage(contentsOfFile: imagePreviewPath)
  224. }
  225. }
  226. if metadata.classFile == NKCommon.TypeClassFile.video.rawValue {
  227. return UIImage(named: "noPreviewVideo")!.image(color: .gray, size: view.frame.width)
  228. } else if metadata.classFile == NKCommon.TypeClassFile.audio.rawValue {
  229. return UIImage(named: "noPreviewAudio")!.image(color: .gray, size: view.frame.width)
  230. } else {
  231. return UIImage(named: "noPreview")!.image(color: .gray, size: view.frame.width)
  232. }
  233. }
  234. func getImage(metadata: tableMetadata) -> UIImage? {
  235. let ext = CCUtility.getExtension(metadata.fileNameView)
  236. var image: UIImage?
  237. if CCUtility.fileProviderStorageExists(metadata) && metadata.classFile == NKCommon.TypeClassFile.image.rawValue {
  238. let previewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
  239. let imagePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
  240. if ext == "GIF" {
  241. if !FileManager().fileExists(atPath: previewPath) {
  242. NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  243. }
  244. image = UIImage.animatedImage(withAnimatedGIFURL: URL(fileURLWithPath: imagePath))
  245. } else if ext == "SVG" {
  246. if let svgImage = SVGKImage(contentsOfFile: imagePath) {
  247. svgImage.size = CGSize(width: NCGlobal.shared.sizePreview, height: NCGlobal.shared.sizePreview)
  248. if let image = svgImage.uiImage {
  249. if !FileManager().fileExists(atPath: previewPath) {
  250. do {
  251. try image.pngData()?.write(to: URL(fileURLWithPath: previewPath), options: .atomic)
  252. } catch { }
  253. }
  254. return image
  255. } else {
  256. return nil
  257. }
  258. } else {
  259. return nil
  260. }
  261. } else {
  262. NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  263. image = UIImage(contentsOfFile: imagePath)
  264. }
  265. }
  266. return image
  267. }
  268. }
  269. // MARK: - Gesture
  270. @objc func didDoubleTapWith(gestureRecognizer: UITapGestureRecognizer) {
  271. if detailView.isShow() { return }
  272. // NO ZOOM for Audio
  273. if metadata.classFile == NKCommon.TypeClassFile.audio.rawValue { return }
  274. let pointInView = gestureRecognizer.location(in: self.imageVideoContainer)
  275. var newZoomScale = self.scrollView.maximumZoomScale
  276. if self.scrollView.zoomScale >= newZoomScale || abs(self.scrollView.zoomScale - newZoomScale) <= 0.01 {
  277. newZoomScale = self.scrollView.minimumZoomScale
  278. }
  279. let width = self.scrollView.bounds.width / newZoomScale
  280. let height = self.scrollView.bounds.height / newZoomScale
  281. let originX = pointInView.x - (width / 2.0)
  282. let originY = pointInView.y - (height / 2.0)
  283. let rectToZoomTo = CGRect(x: originX, y: originY, width: width, height: height)
  284. self.scrollView.zoom(to: rectToZoomTo, animated: true)
  285. }
  286. @objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) {
  287. let currentLocation = gestureRecognizer.translation(in: self.view)
  288. switch gestureRecognizer.state {
  289. case .began:
  290. // let velocity = gestureRecognizer.velocity(in: self.view)
  291. // gesture moving Up
  292. // if velocity.y < 0 {
  293. // }
  294. break
  295. case .ended:
  296. if detailView.isShow() {
  297. self.imageViewTopConstraint.constant = -imageViewConstraint
  298. self.imageViewBottomConstraint.constant = imageViewConstraint
  299. } else {
  300. self.imageViewTopConstraint.constant = 0
  301. self.imageViewBottomConstraint.constant = 0
  302. }
  303. case .changed:
  304. imageViewTopConstraint.constant = (currentLocation.y - imageViewConstraint)
  305. imageViewBottomConstraint.constant = -(currentLocation.y - imageViewConstraint)
  306. // DISMISS VIEW
  307. if detailView.isHidden && (currentLocation.y > 20) {
  308. viewerMediaPage?.navigationController?.popViewController(animated: true)
  309. gestureRecognizer.state = .ended
  310. }
  311. // CLOSE DETAIL
  312. if !detailView.isHidden && (currentLocation.y > 20) {
  313. self.closeDetail()
  314. gestureRecognizer.state = .ended
  315. }
  316. // OPEN DETAIL
  317. if detailView.isHidden && (currentLocation.y < -20) {
  318. self.openDetail()
  319. gestureRecognizer.state = .ended
  320. }
  321. default:
  322. break
  323. }
  324. }
  325. }
  326. // MARK: -
  327. extension NCViewerMedia {
  328. @objc func openDetail(_ notification: NSNotification) {
  329. if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String, ocId == metadata.ocId {
  330. openDetail()
  331. }
  332. }
  333. private func openDetail() {
  334. self.dismissTip()
  335. CCUtility.setExif(metadata) { latitude, longitude, location, date, lensModel in
  336. if latitude != -1 && latitude != 0 && longitude != -1 && longitude != 0 {
  337. self.detailViewHeighConstraint.constant = self.view.bounds.height / 2
  338. } else {
  339. self.detailViewHeighConstraint.constant = 170
  340. }
  341. self.view.layoutIfNeeded()
  342. self.detailView.show(
  343. metadata: self.metadata,
  344. image: self.image,
  345. textColor: self.viewerMediaPage?.textColor,
  346. mediaMetadata: (latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel),
  347. ncplayer: self.ncplayer,
  348. delegate: self)
  349. if let image = self.imageVideoContainer.image {
  350. let ratioW = self.imageVideoContainer.frame.width / image.size.width
  351. let ratioH = self.imageVideoContainer.frame.height / image.size.height
  352. let ratio = ratioW < ratioH ? ratioW : ratioH
  353. let imageHeight = image.size.height * ratio
  354. let VideoContainerHeight = self.imageVideoContainer.frame.height * ratio
  355. let height = max(imageHeight, VideoContainerHeight)
  356. self.imageViewConstraint = self.detailView.frame.height - ((self.view.frame.height - height) / 2) + self.view.safeAreaInsets.bottom
  357. if self.imageViewConstraint < 0 { self.imageViewConstraint = 0 }
  358. }
  359. UIView.animate(withDuration: 0.3) {
  360. self.imageViewTopConstraint.constant = -self.imageViewConstraint
  361. self.imageViewBottomConstraint.constant = self.imageViewConstraint
  362. self.detailViewTopConstraint.constant = self.detailViewHeighConstraint.constant
  363. self.view.layoutIfNeeded()
  364. } completion: { _ in
  365. }
  366. self.scrollView.pinchGestureRecognizer?.isEnabled = false
  367. self.playerToolBar?.hide()
  368. }
  369. }
  370. private func closeDetail() {
  371. self.detailView.hide()
  372. imageViewConstraint = 0
  373. UIView.animate(withDuration: 0.3) {
  374. self.imageViewTopConstraint.constant = 0
  375. self.imageViewBottomConstraint.constant = 0
  376. self.detailViewTopConstraint.constant = 0
  377. self.view.layoutIfNeeded()
  378. } completion: { _ in
  379. }
  380. scrollView.pinchGestureRecognizer?.isEnabled = true
  381. if metadata.classFile == NKCommon.TypeClassFile.video.rawValue && !metadata.livePhoto && !(ncplayer?.isPlay() ?? false) {
  382. NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterShowPlayerToolBar, userInfo: ["ocId": metadata.ocId, "enableTimerAutoHide": false])
  383. }
  384. }
  385. func reloadDetail() {
  386. if self.detailView.isShow() {
  387. CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensModel) in
  388. self.detailView.show(
  389. metadata: self.metadata,
  390. image: self.image,
  391. textColor: self.viewerMediaPage?.textColor,
  392. mediaMetadata: (latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel),
  393. ncplayer: self.ncplayer,
  394. delegate: self)
  395. }
  396. }
  397. }
  398. }
  399. // MARK: -
  400. extension NCViewerMedia: UIScrollViewDelegate {
  401. func viewForZooming(in scrollView: UIScrollView) -> UIView? {
  402. return imageVideoContainer
  403. }
  404. func scrollViewDidZoom(_ scrollView: UIScrollView) {
  405. if scrollView.zoomScale > 1 {
  406. if let image = imageVideoContainer.image {
  407. let ratioW = imageVideoContainer.frame.width / image.size.width
  408. let ratioH = imageVideoContainer.frame.height / image.size.height
  409. let ratio = ratioW < ratioH ? ratioW : ratioH
  410. let newWidth = image.size.width * ratio
  411. let newHeight = image.size.height * ratio
  412. let conditionLeft = newWidth*scrollView.zoomScale > imageVideoContainer.frame.width
  413. let left = 0.5 * (conditionLeft ? newWidth - imageVideoContainer.frame.width : (scrollView.frame.width - scrollView.contentSize.width))
  414. let conditioTop = newHeight*scrollView.zoomScale > imageVideoContainer.frame.height
  415. let top = 0.5 * (conditioTop ? newHeight - imageVideoContainer.frame.height : (scrollView.frame.height - scrollView.contentSize.height))
  416. scrollView.contentInset = UIEdgeInsets(top: top, left: left, bottom: top, right: left)
  417. }
  418. } else {
  419. scrollView.contentInset = .zero
  420. }
  421. }
  422. func scrollViewDidScroll(_ scrollView: UIScrollView) {
  423. }
  424. }
  425. extension NCViewerMedia: NCViewerMediaDetailViewDelegate {
  426. func downloadFullResolution() {
  427. closeDetail()
  428. NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorOpenDetail) { _, _ in }
  429. }
  430. }
  431. extension NCViewerMedia: EasyTipViewDelegate {
  432. // TIP
  433. func easyTipViewDidTap(_ tipView: EasyTipView) {
  434. NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerMediaDetailView)
  435. }
  436. func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
  437. func dismissTip() {
  438. NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerMediaDetailView)
  439. self.tipView?.dismiss()
  440. }
  441. }
  442. // MARK: -
  443. class imageVideoContainerView: UIImageView {
  444. var playerLayer: CALayer?
  445. var metadata: tableMetadata?
  446. override func layoutSublayers(of layer: CALayer) {
  447. super.layoutSublayers(of: layer)
  448. playerLayer?.frame = self.bounds
  449. }
  450. }