NCViewerMedia.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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.postOnMainThread(name: NCGlobal.shared.notificationCenterPauseMedia, userInfo: nil)
  70. NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
  71. }
  72. override func viewDidLoad() {
  73. super.viewDidLoad()
  74. scrollView.delegate = self
  75. scrollView.maximumZoomScale = 4
  76. scrollView.minimumZoomScale = 1
  77. view.addGestureRecognizer(doubleTapGestureRecognizer)
  78. if NCManageDatabase.shared.getMetadataLivePhoto(metadata: metadata) != nil {
  79. statusViewImage.image = NCUtility.shared.loadImage(named: "livephoto", color: .gray)
  80. statusLabel.text = "LIVE"
  81. } else {
  82. statusViewImage.image = nil
  83. statusLabel.text = ""
  84. }
  85. if metadata.classFile == NKCommon.typeClassFile.video.rawValue || metadata.classFile == NKCommon.typeClassFile.audio.rawValue {
  86. playerToolBar = Bundle.main.loadNibNamed("NCPlayerToolBar", owner: self, options: nil)?.first as? NCPlayerToolBar
  87. if let playerToolBar = playerToolBar {
  88. view.addSubview(playerToolBar)
  89. playerToolBar.translatesAutoresizingMaskIntoConstraints = false
  90. playerToolBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
  91. playerToolBar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: 0).isActive = true
  92. playerToolBar.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 0).isActive = true
  93. playerToolBar.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: 0).isActive = true
  94. playerToolBar.viewerMediaPage = viewerMediaPage
  95. }
  96. let urlVideo = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata)
  97. if let url = urlVideo.url {
  98. self.ncplayer = NCPlayer.init(url: url, autoPlay: self.autoPlay, isProxy: urlVideo.isProxy, imageVideoContainer: self.imageVideoContainer, playerToolBar: self.playerToolBar, metadata: self.metadata, detailView: self.detailView, viewController: self)
  99. }
  100. }
  101. // TIP
  102. var preferences = EasyTipView.Preferences()
  103. preferences.drawing.foregroundColor = .white
  104. preferences.drawing.backgroundColor = NCBrandColor.shared.nextcloud
  105. preferences.drawing.textAlignment = .left
  106. preferences.drawing.arrowPosition = .top
  107. preferences.drawing.cornerRadius = 10
  108. preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
  109. preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
  110. preferences.animating.showInitialAlpha = 0
  111. preferences.animating.showDuration = 0.5
  112. preferences.animating.dismissDuration = 0
  113. tipView = EasyTipView(text: NSLocalizedString("_tip_open_mediadetail_", comment: ""), preferences: preferences, delegate: self)
  114. detailViewTopConstraint.constant = 0
  115. detailView.hide()
  116. self.image = nil
  117. self.imageVideoContainer.image = nil
  118. reloadImage()
  119. }
  120. override func viewWillAppear(_ animated: Bool) {
  121. super.viewWillAppear(animated)
  122. viewerMediaPage?.navigationController?.navigationBar.prefersLargeTitles = false
  123. viewerMediaPage?.navigationItem.title = metadata.fileNameView
  124. if metadata.classFile == NKCommon.typeClassFile.image.rawValue, let viewerMediaPage = self.viewerMediaPage {
  125. viewerMediaPage.currentScreenMode = viewerMediaPage.saveScreenModeImage
  126. if viewerMediaPage.modifiedOcId.contains(metadata.ocId) {
  127. viewerMediaPage.modifiedOcId.removeAll(where: { $0 == metadata.ocId })
  128. reloadImage()
  129. }
  130. }
  131. if viewerMediaPage?.currentScreenMode == .full {
  132. viewerMediaPage?.navigationController?.setNavigationBarHidden(true, animated: true)
  133. NCUtility.shared.colorNavigationController(viewerMediaPage?.navigationController, backgroundColor: .black, titleColor: .white, tintColor: nil, withoutShadow: false)
  134. viewerMediaPage?.view.backgroundColor = .black
  135. viewerMediaPage?.textColor = .white
  136. viewerMediaPage?.progressView.isHidden = true
  137. } else {
  138. viewerMediaPage?.navigationController?.setNavigationBarHidden(false, animated: true)
  139. NCUtility.shared.colorNavigationController(viewerMediaPage?.navigationController, backgroundColor: NCBrandColor.shared.systemBackground, titleColor: NCBrandColor.shared.label, tintColor: nil, withoutShadow: false)
  140. viewerMediaPage?.view.backgroundColor = NCBrandColor.shared.systemBackground
  141. viewerMediaPage?.textColor = NCBrandColor.shared.label
  142. viewerMediaPage?.progressView.isHidden = false
  143. }
  144. }
  145. override func viewDidAppear(_ animated: Bool) {
  146. super.viewDidAppear(animated)
  147. if metadata.classFile == NKCommon.typeClassFile.video.rawValue || metadata.classFile == NKCommon.typeClassFile.audio.rawValue {
  148. if let ncplayer = self.ncplayer {
  149. ncplayer.openAVPlayer()
  150. self.viewerMediaPage?.updateCommandCenter(ncplayer: ncplayer, metadata: self.metadata)
  151. }
  152. } else if metadata.classFile == NKCommon.typeClassFile.image.rawValue {
  153. viewerMediaPage?.clearCommandCenter()
  154. }
  155. // TIP
  156. if !NCManageDatabase.shared.tipExists(NCGlobal.shared.tipNCViewerMediaDetailView), let view = self.navigationController?.navigationBar {
  157. self.tipView?.show(forView: view)
  158. }
  159. NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
  160. }
  161. override func viewWillDisappear(_ animated: Bool) {
  162. super.viewWillDisappear(animated)
  163. self.tipView?.dismiss()
  164. }
  165. override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
  166. super.viewWillTransition(to: size, with: coordinator)
  167. self.tipView?.dismiss()
  168. coordinator.animate(alongsideTransition: { context in
  169. // back to the original size
  170. self.scrollView.zoom(to: CGRect(x: 0, y: 0, width: self.scrollView.bounds.width, height: self.scrollView.bounds.height), animated: false)
  171. self.view.layoutIfNeeded()
  172. UIView.animate(withDuration: context.transitionDuration) {
  173. if self.detailView.isShow() {
  174. self.openDetail()
  175. }
  176. }
  177. }) { _ in }
  178. }
  179. // MARK: - Image
  180. func reloadImage() {
  181. if let metadata = NCManageDatabase.shared.getMetadataFromOcId(metadata.ocId) {
  182. self.metadata = metadata
  183. loadImage(metadata: metadata)
  184. }
  185. }
  186. func loadImage(metadata: tableMetadata) {
  187. // Download image
  188. if !CCUtility.fileProviderStorageExists(metadata) && metadata.classFile == NKCommon.typeClassFile.image.rawValue && metadata.session == "" {
  189. if metadata.livePhoto {
  190. let fileName = (metadata.fileNameView as NSString).deletingPathExtension + ".mov"
  191. if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !CCUtility.fileProviderStorageExists(metadata) {
  192. NCNetworking.shared.download(metadata: metadata, selector: "") { _, _ in }
  193. }
  194. }
  195. NCNetworking.shared.download(metadata: metadata, selector: "") { _, _ in
  196. let image = getImageMetadata(metadata)
  197. if self.metadata.ocId == metadata.ocId && self.imageVideoContainer.layer.sublayers?.count == nil {
  198. self.image = image
  199. self.imageVideoContainer.image = image
  200. }
  201. }
  202. }
  203. // Get image
  204. let image = getImageMetadata(metadata)
  205. if self.metadata.ocId == metadata.ocId && self.imageVideoContainer.layer.sublayers?.count == nil {
  206. self.image = image
  207. self.imageVideoContainer.image = image
  208. }
  209. func getImageMetadata(_ metadata: tableMetadata) -> UIImage? {
  210. if let image = getImage(metadata: metadata) {
  211. return image
  212. }
  213. if metadata.classFile == NKCommon.typeClassFile.video.rawValue && !metadata.hasPreview {
  214. NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  215. }
  216. if CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) {
  217. if let imagePreviewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag) {
  218. return UIImage(contentsOfFile: imagePreviewPath)
  219. }
  220. }
  221. if metadata.classFile == NKCommon.typeClassFile.video.rawValue {
  222. return UIImage(named: "noPreviewVideo")!.image(color: .gray, size: view.frame.width)
  223. } else if metadata.classFile == NKCommon.typeClassFile.audio.rawValue {
  224. return UIImage(named: "noPreviewAudio")!.image(color: .gray, size: view.frame.width)
  225. } else {
  226. return UIImage(named: "noPreview")!.image(color: .gray, size: view.frame.width)
  227. }
  228. }
  229. func getImage(metadata: tableMetadata) -> UIImage? {
  230. let ext = CCUtility.getExtension(metadata.fileNameView)
  231. var image: UIImage?
  232. if CCUtility.fileProviderStorageExists(metadata) && metadata.classFile == NKCommon.typeClassFile.image.rawValue {
  233. let previewPath = CCUtility.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)!
  234. let imagePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
  235. if ext == "GIF" {
  236. if !FileManager().fileExists(atPath: previewPath) {
  237. NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  238. }
  239. image = UIImage.animatedImage(withAnimatedGIFURL: URL(fileURLWithPath: imagePath))
  240. } else if ext == "SVG" {
  241. if let svgImage = SVGKImage(contentsOfFile: imagePath) {
  242. svgImage.size = CGSize(width: NCGlobal.shared.sizePreview, height: NCGlobal.shared.sizePreview)
  243. if let image = svgImage.uiImage {
  244. if !FileManager().fileExists(atPath: previewPath) {
  245. do {
  246. try image.pngData()?.write(to: URL(fileURLWithPath: previewPath), options: .atomic)
  247. } catch { }
  248. }
  249. return image
  250. } else {
  251. return nil
  252. }
  253. } else {
  254. return nil
  255. }
  256. } else {
  257. NCUtility.shared.createImageFrom(fileNameView: metadata.fileNameView, ocId: metadata.ocId, etag: metadata.etag, classFile: metadata.classFile)
  258. image = UIImage(contentsOfFile: imagePath)
  259. }
  260. }
  261. return image
  262. }
  263. }
  264. // MARK: - Gesture
  265. @objc func didDoubleTapWith(gestureRecognizer: UITapGestureRecognizer) {
  266. if detailView.isShow() { return }
  267. // NO ZOOM for Audio
  268. if metadata.classFile == NKCommon.typeClassFile.audio.rawValue { return }
  269. let pointInView = gestureRecognizer.location(in: self.imageVideoContainer)
  270. var newZoomScale = self.scrollView.maximumZoomScale
  271. if self.scrollView.zoomScale >= newZoomScale || abs(self.scrollView.zoomScale - newZoomScale) <= 0.01 {
  272. newZoomScale = self.scrollView.minimumZoomScale
  273. }
  274. let width = self.scrollView.bounds.width / newZoomScale
  275. let height = self.scrollView.bounds.height / newZoomScale
  276. let originX = pointInView.x - (width / 2.0)
  277. let originY = pointInView.y - (height / 2.0)
  278. let rectToZoomTo = CGRect(x: originX, y: originY, width: width, height: height)
  279. self.scrollView.zoom(to: rectToZoomTo, animated: true)
  280. }
  281. @objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) {
  282. let currentLocation = gestureRecognizer.translation(in: self.view)
  283. switch gestureRecognizer.state {
  284. case .began:
  285. // let velocity = gestureRecognizer.velocity(in: self.view)
  286. // gesture moving Up
  287. // if velocity.y < 0 {
  288. // }
  289. break
  290. case .ended:
  291. if detailView.isShow() {
  292. self.imageViewTopConstraint.constant = -imageViewConstraint
  293. self.imageViewBottomConstraint.constant = imageViewConstraint
  294. } else {
  295. self.imageViewTopConstraint.constant = 0
  296. self.imageViewBottomConstraint.constant = 0
  297. }
  298. case .changed:
  299. imageViewTopConstraint.constant = (currentLocation.y - imageViewConstraint)
  300. imageViewBottomConstraint.constant = -(currentLocation.y - imageViewConstraint)
  301. // DISMISS VIEW
  302. if detailView.isHidden && (currentLocation.y > 20) {
  303. viewerMediaPage?.navigationController?.popViewController(animated: true)
  304. gestureRecognizer.state = .ended
  305. }
  306. // CLOSE DETAIL
  307. if !detailView.isHidden && (currentLocation.y > 20) {
  308. self.closeDetail()
  309. gestureRecognizer.state = .ended
  310. }
  311. // OPEN DETAIL
  312. if detailView.isHidden && (currentLocation.y < -20) {
  313. self.openDetail()
  314. gestureRecognizer.state = .ended
  315. }
  316. default:
  317. break
  318. }
  319. }
  320. }
  321. // MARK: -
  322. extension NCViewerMedia {
  323. @objc func openDetail(_ notification: NSNotification) {
  324. if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String, ocId == metadata.ocId {
  325. openDetail()
  326. }
  327. }
  328. private func openDetail() {
  329. self.dismissTip()
  330. CCUtility.setExif(metadata) { latitude, longitude, location, date, lensModel in
  331. if latitude != -1 && latitude != 0 && longitude != -1 && longitude != 0 {
  332. self.detailViewHeighConstraint.constant = self.view.bounds.height / 2
  333. } else {
  334. self.detailViewHeighConstraint.constant = 170
  335. }
  336. self.view.layoutIfNeeded()
  337. self.detailView.show(
  338. metadata: self.metadata,
  339. image: self.image,
  340. textColor: self.viewerMediaPage?.textColor,
  341. mediaMetadata: (latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel),
  342. ncplayer: self.ncplayer,
  343. delegate: self)
  344. if let image = self.imageVideoContainer.image {
  345. let ratioW = self.imageVideoContainer.frame.width / image.size.width
  346. let ratioH = self.imageVideoContainer.frame.height / image.size.height
  347. let ratio = ratioW < ratioH ? ratioW : ratioH
  348. let imageHeight = image.size.height * ratio
  349. self.imageViewConstraint = self.detailView.frame.height - ((self.view.frame.height - imageHeight) / 2) + self.view.safeAreaInsets.bottom
  350. if self.imageViewConstraint < 0 { self.imageViewConstraint = 0 }
  351. }
  352. UIView.animate(withDuration: 0.3) {
  353. self.imageViewTopConstraint.constant = -self.imageViewConstraint
  354. self.imageViewBottomConstraint.constant = self.imageViewConstraint
  355. self.detailViewTopConstraint.constant = self.detailViewHeighConstraint.constant
  356. self.view.layoutIfNeeded()
  357. } completion: { _ in
  358. }
  359. self.scrollView.pinchGestureRecognizer?.isEnabled = false
  360. self.playerToolBar?.hide()
  361. }
  362. }
  363. private func closeDetail() {
  364. self.detailView.hide()
  365. imageViewConstraint = 0
  366. UIView.animate(withDuration: 0.3) {
  367. self.imageViewTopConstraint.constant = 0
  368. self.imageViewBottomConstraint.constant = 0
  369. self.detailViewTopConstraint.constant = 0
  370. self.view.layoutIfNeeded()
  371. } completion: { _ in
  372. }
  373. scrollView.pinchGestureRecognizer?.isEnabled = true
  374. if metadata.classFile == NKCommon.typeClassFile.video.rawValue && !metadata.livePhoto && ncplayer?.player?.timeControlStatus == .paused {
  375. NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterShowPlayerToolBar, userInfo: ["ocId": metadata.ocId, "enableTimerAutoHide": false])
  376. }
  377. }
  378. func reloadDetail() {
  379. if self.detailView.isShow() {
  380. CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensModel) in
  381. self.detailView.show(
  382. metadata: self.metadata,
  383. image: self.image,
  384. textColor: self.viewerMediaPage?.textColor,
  385. mediaMetadata: (latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel),
  386. ncplayer: self.ncplayer,
  387. delegate: self)
  388. }
  389. }
  390. }
  391. }
  392. // MARK: -
  393. extension NCViewerMedia: UIScrollViewDelegate {
  394. func viewForZooming(in scrollView: UIScrollView) -> UIView? {
  395. return imageVideoContainer
  396. }
  397. func scrollViewDidZoom(_ scrollView: UIScrollView) {
  398. if scrollView.zoomScale > 1 {
  399. if let image = imageVideoContainer.image {
  400. let ratioW = imageVideoContainer.frame.width / image.size.width
  401. let ratioH = imageVideoContainer.frame.height / image.size.height
  402. let ratio = ratioW < ratioH ? ratioW : ratioH
  403. let newWidth = image.size.width * ratio
  404. let newHeight = image.size.height * ratio
  405. let conditionLeft = newWidth*scrollView.zoomScale > imageVideoContainer.frame.width
  406. let left = 0.5 * (conditionLeft ? newWidth - imageVideoContainer.frame.width : (scrollView.frame.width - scrollView.contentSize.width))
  407. let conditioTop = newHeight*scrollView.zoomScale > imageVideoContainer.frame.height
  408. let top = 0.5 * (conditioTop ? newHeight - imageVideoContainer.frame.height : (scrollView.frame.height - scrollView.contentSize.height))
  409. scrollView.contentInset = UIEdgeInsets(top: top, left: left, bottom: top, right: left)
  410. }
  411. } else {
  412. scrollView.contentInset = .zero
  413. }
  414. }
  415. func scrollViewDidScroll(_ scrollView: UIScrollView) {
  416. }
  417. }
  418. extension NCViewerMedia: NCViewerMediaDetailViewDelegate {
  419. func downloadFullResolution() {
  420. closeDetail()
  421. NCNetworking.shared.download(metadata: metadata, selector: NCGlobal.shared.selectorOpenDetail) { _, _ in }
  422. }
  423. }
  424. extension NCViewerMedia: EasyTipViewDelegate {
  425. // TIP
  426. func easyTipViewDidTap(_ tipView: EasyTipView) {
  427. NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerMediaDetailView)
  428. }
  429. func easyTipViewDidDismiss(_ tipView: EasyTipView) { }
  430. func dismissTip() {
  431. NCManageDatabase.shared.addTip(NCGlobal.shared.tipNCViewerMediaDetailView)
  432. self.tipView?.dismiss()
  433. }
  434. }
  435. // MARK: -
  436. class imageVideoContainerView: UIImageView {
  437. var playerLayer: CALayer?
  438. var metadata: tableMetadata?
  439. override func layoutSublayers(of layer: CALayer) {
  440. super.layoutSublayers(of: layer)
  441. playerLayer?.frame = self.bounds
  442. }
  443. }