Эх сурвалжийг харах

added fullscreen movie

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 жил өмнө
parent
commit
da9ccf2584

+ 11 - 1
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -124,8 +124,18 @@ class NCPlayer: NSObject {
     // MARK: - UIGestureRecognizerDelegate
 
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
+        changeScreenMode()
+    }
+
+    func changeScreenMode() {
+
+        guard let viewerMediaPage = viewerMediaPage, let playerToolBar = self.playerToolBar else { return }
 
-        viewerMediaPage?.didSingleTapWith(gestureRecognizer: gestureRecognizer)
+        if viewerMediaScreenMode == .full {
+            viewerMediaPage.changeScreenMode(mode: .normal, isMovie: true, fullscreen: playerToolBar.isFullscreen)
+        } else {
+            viewerMediaPage.changeScreenMode(mode: .full, isMovie: true, fullscreen: playerToolBar.isFullscreen)
+        }
     }
 
     // MARK: - NotificationCenter

+ 22 - 9
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -33,6 +33,7 @@ import FloatingPanel
 class NCPlayerToolBar: UIView {
 
     @IBOutlet weak var utilityView: UIStackView!
+    @IBOutlet weak var fullscreenButton: UIButton!
     @IBOutlet weak var subtitleButton: UIButton!
     @IBOutlet weak var audioButton: UIButton!
 
@@ -52,15 +53,14 @@ class NCPlayerToolBar: UIView {
         case moved
     }
     var playbackSliderEvent: sliderEventType = .ended
+    var isFullscreen: Bool = false
 
     private var ncplayer: NCPlayer?
     private var metadata: tableMetadata?
     private let audioSession = AVAudioSession.sharedInstance()
     private var subTitleIndex: Int32?
     private var audioIndex: Int32?
-
     private var pointSize: CGFloat = 0
-    
     private weak var viewerMediaPage: NCViewerMediaPage?
 
     // MARK: - View Life Cycle
@@ -68,6 +68,8 @@ class NCPlayerToolBar: UIView {
     override func awakeFromNib() {
         super.awakeFromNib()
 
+        fullscreenButton.setImage(NCUtility.shared.loadImage(named: "arrow.up.left.and.arrow.down.right", color: .white), for: .normal)
+
         subtitleButton.setImage(NCUtility.shared.loadImage(named: "captions.bubble", color: .white), for: .normal)
         subtitleButton.isEnabled = false
 
@@ -229,16 +231,15 @@ class NCPlayerToolBar: UIView {
 
     @objc func tap(gestureRecognizer: UITapGestureRecognizer) { }
 
-    @IBAction func tapPlayerPause(_ sender: Any) {
-        guard let ncplayer = ncplayer else { return }
+    @IBAction func tapFullscreen(_ sender: Any) {
 
-        if ncplayer.isPlay() {
-            ncplayer.playerPause()
+        isFullscreen = !isFullscreen
+        if isFullscreen {
+            fullscreenButton.setImage(NCUtility.shared.loadImage(named: "arrow.down.right.and.arrow.up.left", color: .white), for: .normal)
         } else {
-            ncplayer.playerPlay()
+            fullscreenButton.setImage(NCUtility.shared.loadImage(named: "arrow.up.left.and.arrow.down.right", color: .white), for: .normal)
         }
-
-        self.viewerMediaPage?.startTimerAutoHide()
+        ncplayer?.changeScreenMode()
     }
 
     @IBAction func tapSubTitle(_ sender: Any) {
@@ -267,6 +268,18 @@ class NCPlayerToolBar: UIView {
         }
     }
 
+    @IBAction func tapPlayerPause(_ sender: Any) {
+        guard let ncplayer = ncplayer else { return }
+
+        if ncplayer.isPlay() {
+            ncplayer.playerPause()
+        } else {
+            ncplayer.playerPlay()
+        }
+
+        self.viewerMediaPage?.startTimerAutoHide()
+    }
+
     @IBAction func tapForward(_ sender: Any) {
 
         guard let ncplayer = ncplayer else { return }

+ 11 - 1
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.xib

@@ -15,7 +15,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <stackView opaque="NO" contentMode="scaleToFill" distribution="equalCentering" alignment="center" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="XfW-XC-eMf" userLabel="Player Top Tool Bar">
-                    <rect key="frame" x="297" y="0.0" width="78" height="52"/>
+                    <rect key="frame" x="256" y="0.0" width="119" height="52"/>
                     <subviews>
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qqZ-QN-TsW">
                             <rect key="frame" x="5" y="25" width="22.5" height="22"/>
@@ -33,6 +33,14 @@
                                 <action selector="tapAudio:" destination="iN0-l3-epB" eventType="touchUpInside" id="EVU-fE-n5T"/>
                             </connections>
                         </button>
+                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oOw-fT-A3E">
+                            <rect key="frame" x="94" y="25" width="20" height="22"/>
+                            <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                            <state key="normal" image="arrow.up.left.and.arrow.down.right" catalog="system"/>
+                            <connections>
+                                <action selector="tapFullscreen:" destination="iN0-l3-epB" eventType="touchUpInside" id="HC5-4P-VQi"/>
+                            </connections>
+                        </button>
                     </subviews>
                     <directionalEdgeInsets key="directionalLayoutMargins" top="5" leading="5" bottom="5" trailing="5"/>
                 </stackView>
@@ -114,6 +122,7 @@
                 <outlet property="audioButton" destination="sMY-qo-4CE" id="R7Q-de-Dsv"/>
                 <outlet property="backButton" destination="xja-nq-uD3" id="l3U-Mo-DEL"/>
                 <outlet property="forwardButton" destination="5Zd-By-Fko" id="ocQ-YT-Rwm"/>
+                <outlet property="fullscreenButton" destination="oOw-fT-A3E" id="D9a-Tf-vzm"/>
                 <outlet property="labelCurrentTime" destination="OHB-2J-Gqb" id="pFy-CJ-x2A"/>
                 <outlet property="labelLeftTime" destination="svM-TQ-AyQ" id="UDV-Lh-12z"/>
                 <outlet property="playButton" destination="qo0-x8-OfL" id="m4a-gb-D0J"/>
@@ -127,6 +136,7 @@
         </view>
     </objects>
     <resources>
+        <image name="arrow.up.left.and.arrow.down.right" catalog="system" width="128" height="115"/>
         <image name="captions.bubble" catalog="system" width="128" height="110"/>
         <image name="gobackward.10" catalog="system" width="119" height="128"/>
         <image name="goforward.10" catalog="system" width="119" height="128"/>

+ 17 - 6
iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift

@@ -212,15 +212,22 @@ class NCViewerMediaPage: UIViewController {
         NCViewer.shared.toggleMenu(viewController: self, metadata: currentViewController.metadata, webView: false, imageIcon: imageIcon)
     }
 
-    func changeScreenMode(mode: ScreenMode, isMovie: Bool = false) {
+    func changeScreenMode(mode: ScreenMode, isMovie: Bool = false, fullscreen: Bool = false) {
 
         let metadata = metadatas[currentIndex]
+        NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .systemBackground, titleColor: .label, tintColor: nil, withoutShadow: false)
 
         if mode == .normal {
 
-            navigationController?.setNavigationBarHidden(false, animated: true)
-            hideStatusBar = false
-            progressView.isHidden = false
+            if fullscreen {
+                navigationController?.setNavigationBarHidden(true, animated: true)
+                hideStatusBar = true
+                progressView.isHidden = true
+            } else {
+                navigationController?.setNavigationBarHidden(false, animated: true)
+                hideStatusBar = false
+                progressView.isHidden = false
+            }
 
             if metadata.isMovie || isMovie {
                 currentViewController.playerToolBar?.show()
@@ -231,8 +238,6 @@ class NCViewerMediaPage: UIViewController {
                 textColor = .label
             }
 
-            NCUtility.shared.colorNavigationController(navigationController, backgroundColor: .systemBackground, titleColor: .label, tintColor: nil, withoutShadow: false)
-
         } else {
 
             navigationController?.setNavigationBarHidden(true, animated: true)
@@ -247,6 +252,12 @@ class NCViewerMediaPage: UIViewController {
             textColor = .white
         }
 
+        if fullscreen {
+            pageViewController.disableSwipeGesture()
+        } else {
+            pageViewController.enableSwipeGesture()
+        }
+
         viewerMediaScreenMode = mode
         print("Screen mode: \(viewerMediaScreenMode)")