Marino Faggiana 2 yıl önce
ebeveyn
işleme
b223385a7c

+ 5 - 25
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -64,25 +64,12 @@ class NCPlayer: NSObject {
         fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!
 
         super.init()
-
-        do {
-            try AVAudioSession.sharedInstance().setCategory(.playback)
-            try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSession.PortOverride.none)
-            try AVAudioSession.sharedInstance().setActive(true)
-        } catch {
-            print(error)
-        }
     }
 
     deinit {
 
         print("deinit NCPlayer with ocId \(metadata.ocId)")
-
         player?.stop()
-
-        if let playerToolBar = self.playerToolBar, playerToolBar.isPictureInPictureActive() {
-            playerToolBar.pictureInPictureController?.stopPictureInPicture()
-        }
     }
 
     func openAVPlayer(url: URL) {
@@ -154,10 +141,8 @@ class NCPlayer: NSObject {
 
     @objc func applicationDidEnterBackground(_ notification: NSNotification) {
 
-        if metadata.classFile == NKCommon.TypeClassFile.video.rawValue, let playerToolBar = self.playerToolBar {
-            if !playerToolBar.isPictureInPictureActive() {
-                playerPause()
-            }
+        if metadata.classFile == NKCommon.TypeClassFile.video.rawValue {
+            playerPause()
         }
     }
 
@@ -193,10 +178,6 @@ class NCPlayer: NSObject {
 
         player?.pause()
         playerToolBar?.update(position: player?.position)
-
-        if let playerToolBar = self.playerToolBar, playerToolBar.isPictureInPictureActive() {
-            playerToolBar.pictureInPictureController?.stopPictureInPicture()
-        }
     }
 
     func videoSeek(position: Float) {
@@ -276,20 +257,19 @@ extension NCPlayer: VLCMediaPlayerDelegate {
     }
 
     func mediaPlayerTimeChanged(_ aNotification: Notification) {
-
         self.playerToolBar?.update(position: player?.position)
     }
 
     func mediaPlayerTitleChanged(_ aNotification: Notification) {
-        print(".")
+        // Handle other states...
     }
 
     func mediaPlayerChapterChanged(_ aNotification: Notification) {
-        print(".")
+        // Handle other states...
     }
 
     func mediaPlayerLoudnessChanged(_ aNotification: Notification) {
-        print(".")
+        // Handle other states...
     }
 
     func mediaPlayerSnapshot(_ aNotification: Notification) {

+ 0 - 61
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -33,8 +33,6 @@ class NCPlayerToolBar: UIView {
 
     @IBOutlet weak var playerTopToolBarView: UIStackView!
     @IBOutlet weak var playerToolBarView: UIView!
-    @IBOutlet weak var pipButton: UIButton!
-    @IBOutlet weak var subtitleButton: UIButton!
     @IBOutlet weak var muteButton: UIButton!
     @IBOutlet weak var playButton: UIButton!
     @IBOutlet weak var forwardButton: UIButton!
@@ -65,7 +63,6 @@ class NCPlayerToolBar: UIView {
         }
     }
 
-    var pictureInPictureController: AVPictureInPictureController?
     weak var viewerMediaPage: NCViewerMediaPage?
 
     // MARK: - View Life Cycle
@@ -89,16 +86,9 @@ class NCPlayerToolBar: UIView {
         playerToolBarView.layer.masksToBounds = true
         playerToolBarView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapToolBarWith(gestureRecognizer:))))
 
-        pipButton.setImage(NCUtility.shared.loadImage(named: "pip.enter", color: .lightGray), for: .normal)
-        pipButton.isEnabled = false
-
         muteButton.setImage(NCUtility.shared.loadImage(named: "audioOff", color: .lightGray), for: .normal)
         muteButton.isEnabled = false
 
-        subtitleButton.setImage(NCUtility.shared.loadImage(named: "captions.bubble", color: .white), for: .normal)
-        subtitleButton.isEnabled = true
-        subtitleButton.isHidden = true
-
         playbackSlider.value = 0
         playbackSlider.minimumValue = 0
         playbackSlider.maximumValue = 1
@@ -127,9 +117,6 @@ class NCPlayerToolBar: UIView {
 
     deinit {
         print("deinit NCPlayerToolBar")
-
-        NotificationCenter.default.removeObserver(self, name: AVAudioSession.interruptionNotification, object: nil)
-        NotificationCenter.default.removeObserver(self, name: AVAudioSession.routeChangeNotification, object: nil)
     }
 
     // MARK: -
@@ -154,7 +141,6 @@ class NCPlayerToolBar: UIView {
 
     public func buffering() {
 
-        pipButton.isEnabled = false
         muteButton.isEnabled = false
         playButton.isEnabled = false
         forwardButton.isEnabled = false
@@ -184,17 +170,6 @@ class NCPlayerToolBar: UIView {
             muteButton.isEnabled = true
         }
 
-        // PIP
-        if let pipButton = pipButton {
-            if metadata?.classFile == NKCommon.TypeClassFile.video.rawValue && AVPictureInPictureController.isPictureInPictureSupported() {
-                pipButton.setImage(NCUtility.shared.loadImage(named: "pip.enter", color: .white), for: .normal)
-                pipButton.isEnabled = true
-            } else {
-                pipButton.setImage(NCUtility.shared.loadImage(named: "pip.enter", color: .gray), for: .normal)
-                pipButton.isEnabled = false
-            }
-        }
-
         // SLIDER TIME (START - END)
         playbackSlider.value = position
         playbackSlider.isEnabled = true
@@ -290,15 +265,6 @@ class NCPlayerToolBar: UIView {
         reStartTimerAutoHide()
     }
 
-    func isPictureInPictureActive() -> Bool {
-
-        if let pictureInPictureController = self.pictureInPictureController, pictureInPictureController.isPictureInPictureActive {
-            return true
-        } else {
-            return false
-        }
-    }
-
     func stopTimerAutoHide() {
 
         timerAutoHide?.invalidate()
@@ -364,29 +330,6 @@ class NCPlayerToolBar: UIView {
         reStartTimerAutoHide()
     }
 
-    @IBAction func tapPip(_ sender: Any) {
-
-        /*
-        guard let videoLayer = ncplayer?.videoLayer else { return }
-
-        if let pictureInPictureController = self.pictureInPictureController, pictureInPictureController.isPictureInPictureActive {
-            pictureInPictureController.stopPictureInPicture()
-        }
-
-        if pictureInPictureController == nil {
-            pictureInPictureController = AVPictureInPictureController(playerLayer: videoLayer)
-            pictureInPictureController?.delegate = self
-        }
-
-        if let pictureInPictureController = pictureInPictureController, pictureInPictureController.isPictureInPicturePossible, let metadata = self.metadata {
-            DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
-                pictureInPictureController.startPictureInPicture()
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterHidePlayerToolBar, userInfo: ["ocId": metadata.ocId])
-            }
-        }
-        */
-    }
-
     @IBAction func tapForward(_ sender: Any) {
 
         skip(seconds: 10)
@@ -397,10 +340,6 @@ class NCPlayerToolBar: UIView {
         skip(seconds: -10)
     }
 
-    @IBAction func tapSubtitle(_ sender: Any) {
-
-    }
-
     func forward() {
 
         var index: Int = 0

+ 7 - 34
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
         <capability name="Image references" minToolsVersion="12.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -16,33 +16,10 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="XfW-XC-eMf" userLabel="Player Top Tool Bar">
-                    <rect key="frame" x="299" y="54" width="105" height="35"/>
+                    <rect key="frame" x="369" y="58" width="35" height="35"/>
                     <subviews>
-                        <button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a3d-ja-utA">
-                            <rect key="frame" x="5" y="5" width="25" height="25"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="25" id="TIW-zu-jSX"/>
-                                <constraint firstAttribute="width" constant="25" id="jR3-bv-VnZ"/>
-                            </constraints>
-                            <state key="normal" image="pip.enter" catalog="system"/>
-                            <connections>
-                                <action selector="tapPip:" destination="iN0-l3-epB" eventType="touchUpInside" id="fB5-g1-OnB"/>
-                            </connections>
-                        </button>
-                        <button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Mqe-Hd-USv">
-                            <rect key="frame" x="40" y="5" width="25" height="25"/>
-                            <constraints>
-                                <constraint firstAttribute="width" constant="25" id="HQs-6R-hb9"/>
-                                <constraint firstAttribute="height" constant="25" id="s43-Qc-Shn"/>
-                            </constraints>
-                            <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
-                            <state key="normal" image="captions.bubble" catalog="system"/>
-                            <connections>
-                                <action selector="tapSubtitle:" destination="iN0-l3-epB" eventType="touchUpInside" id="Cxi-6E-bKD"/>
-                            </connections>
-                        </button>
                         <button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fml-c2-FMY">
-                            <rect key="frame" x="75" y="5" width="25" height="25"/>
+                            <rect key="frame" x="5" y="5" width="25" height="25"/>
                             <constraints>
                                 <constraint firstAttribute="width" constant="25" id="S8g-UR-4zh"/>
                                 <constraint firstAttribute="height" constant="25" id="zjo-O1-SI2"/>
@@ -157,22 +134,18 @@
                 <outlet property="labelCurrentTime" destination="OHB-2J-Gqb" id="pFy-CJ-x2A"/>
                 <outlet property="labelLeftTime" destination="svM-TQ-AyQ" id="UDV-Lh-12z"/>
                 <outlet property="muteButton" destination="Fml-c2-FMY" id="Fo1-Ep-ZPz"/>
-                <outlet property="pipButton" destination="a3d-ja-utA" id="9nt-RD-IXd"/>
                 <outlet property="playButton" destination="hx9-d5-yiD" id="Enk-Ge-2Yx"/>
                 <outlet property="playbackSlider" destination="MY0-FC-j88" id="bVe-Kc-80k"/>
                 <outlet property="playerToolBarView" destination="85m-50-8yp" id="eZK-p1-v65"/>
                 <outlet property="playerTopToolBarView" destination="XfW-XC-eMf" id="Qdp-IW-YhT"/>
-                <outlet property="subtitleButton" destination="Mqe-Hd-USv" id="ZHN-bf-WT5"/>
             </connections>
             <point key="canvasLocation" x="137.68115942028987" y="152.67857142857142"/>
         </view>
     </objects>
     <resources>
         <image name="audioOn" width="28" height="28"/>
-        <image name="captions.bubble" catalog="system" width="128" height="110"/>
-        <image name="gobackward.10" catalog="system" width="121" height="128"/>
-        <image name="goforward.10" catalog="system" width="121" height="128"/>
-        <image name="pip.enter" catalog="system" width="128" height="96"/>
-        <image name="play.fill" catalog="system" width="116" height="128"/>
+        <image name="gobackward.10" catalog="system" width="119" height="128"/>
+        <image name="goforward.10" catalog="system" width="119" height="128"/>
+        <image name="play.fill" catalog="system" width="117" height="128"/>
     </resources>
 </document>

+ 1 - 5
iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift

@@ -346,7 +346,7 @@ class NCViewerMediaPage: UIViewController {
     @objc func showPlayerToolBar(_ notification: NSNotification) {
 
         if let userInfo = notification.userInfo as NSDictionary?, let ocId = userInfo["ocId"] as? String, let enableTimerAutoHide = userInfo["enableTimerAutoHide"] as? Bool {
-            if currentViewController.metadata.ocId == ocId, let playerToolBar = currentViewController.playerToolBar, !playerToolBar.isPictureInPictureActive() {
+            if currentViewController.metadata.ocId == ocId {
                 changeScreenMode(mode: .normal, enableTimerAutoHide: enableTimerAutoHide)
             }
         }
@@ -579,10 +579,6 @@ extension NCViewerMediaPage: UIGestureRecognizerDelegate {
 
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
 
-        if let playerToolBar = currentViewController.playerToolBar, playerToolBar.isPictureInPictureActive() {
-            playerToolBar.pictureInPictureController?.stopPictureInPicture()
-        }
-
         if currentScreenMode == .full {
             changeScreenMode(mode: .normal, enableTimerAutoHide: true)
         } else {