NCViewerMedia.swift 23 KB

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