marinofaggiana 3 жил өмнө
parent
commit
30176c79cb

+ 33 - 3
iOSClient/Viewer/NCViewerImage/NCViewerImage.storyboard

@@ -244,10 +244,10 @@
                                         <rect key="frame" x="25" y="636" width="364" height="100"/>
                                         <subviews>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8AB-hx-yqN">
-                                                <rect key="frame" x="324" y="60" width="30" height="30"/>
+                                                <rect key="frame" x="329" y="65" width="25" height="25"/>
                                                 <constraints>
-                                                    <constraint firstAttribute="width" constant="30" id="6yU-23-dkA"/>
-                                                    <constraint firstAttribute="height" constant="30" id="hBk-Ku-BAd"/>
+                                                    <constraint firstAttribute="width" constant="25" id="6yU-23-dkA"/>
+                                                    <constraint firstAttribute="height" constant="25" id="hBk-Ku-BAd"/>
                                                 </constraints>
                                                 <color key="tintColor" systemColor="labelColor"/>
                                                 <state key="normal" image="audioOn"/>
@@ -282,15 +282,41 @@
                                                 <nil key="textColor"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
+                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F9L-PP-AbM">
+                                                <rect key="frame" x="217.00000000000003" y="63.666666666666629" width="20" height="23"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="20" id="hlL-XQ-OLa"/>
+                                                    <constraint firstAttribute="height" constant="23" id="vEe-Fb-a9N"/>
+                                                </constraints>
+                                                <state key="normal" image="goforward.15" catalog="system"/>
+                                                <connections>
+                                                    <action selector="forwardButtonSec:" destination="sBp-t2-eFh" eventType="touchUpInside" id="QPi-TQ-rNF"/>
+                                                </connections>
+                                            </button>
+                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Isy-sX-Gji">
+                                                <rect key="frame" x="117" y="63.666666666666629" width="20" height="23"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="20" id="COm-r2-ubw"/>
+                                                    <constraint firstAttribute="height" constant="23" id="mbb-ql-zCc"/>
+                                                </constraints>
+                                                <state key="normal" image="gobackward.15" catalog="system"/>
+                                                <connections>
+                                                    <action selector="backButtonSec:" destination="sBp-t2-eFh" eventType="touchUpInside" id="Q46-Tp-inF"/>
+                                                </connections>
+                                            </button>
                                         </subviews>
                                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <constraints>
                                             <constraint firstAttribute="trailing" secondItem="8AB-hx-yqN" secondAttribute="trailing" constant="10" id="4LY-8e-z3y"/>
+                                            <constraint firstItem="F9L-PP-AbM" firstAttribute="leading" secondItem="x3E-b2-obf" secondAttribute="trailing" constant="20" id="5uf-6l-2qg"/>
                                             <constraint firstAttribute="bottom" secondItem="x3E-b2-obf" secondAttribute="bottom" constant="10" id="7W8-qk-uwn"/>
                                             <constraint firstAttribute="bottom" secondItem="8AB-hx-yqN" secondAttribute="bottom" constant="10" id="CUW-6d-CGn"/>
                                             <constraint firstAttribute="height" constant="100" id="EyI-HW-pHA"/>
+                                            <constraint firstItem="Isy-sX-Gji" firstAttribute="centerY" secondItem="x3E-b2-obf" secondAttribute="centerY" id="Hif-Fa-xc2"/>
+                                            <constraint firstItem="x3E-b2-obf" firstAttribute="leading" secondItem="Isy-sX-Gji" secondAttribute="trailing" constant="30" id="HqJ-Pz-igl"/>
                                             <constraint firstAttribute="trailing" secondItem="SR4-e8-1hC" secondAttribute="trailing" constant="10" id="Q3r-ex-Cpf"/>
                                             <constraint firstItem="SR4-e8-1hC" firstAttribute="leading" secondItem="sBp-t2-eFh" secondAttribute="leading" constant="10" id="Xec-gd-9AB"/>
+                                            <constraint firstItem="F9L-PP-AbM" firstAttribute="centerY" secondItem="x3E-b2-obf" secondAttribute="centerY" id="cIu-i5-mbJ"/>
                                             <constraint firstAttribute="trailing" secondItem="OUD-HH-cXH" secondAttribute="trailing" constant="10" id="j5v-RG-0JI"/>
                                             <constraint firstItem="kVv-X4-6SK" firstAttribute="top" secondItem="SR4-e8-1hC" secondAttribute="bottom" id="l6a-l5-ZvL"/>
                                             <constraint firstItem="x3E-b2-obf" firstAttribute="centerX" secondItem="sBp-t2-eFh" secondAttribute="centerX" id="uPa-tM-Vx6"/>
@@ -299,6 +325,8 @@
                                             <constraint firstItem="kVv-X4-6SK" firstAttribute="leading" secondItem="sBp-t2-eFh" secondAttribute="leading" constant="10" id="yee-JQ-gRq"/>
                                         </constraints>
                                         <connections>
+                                            <outlet property="backButton" destination="Isy-sX-Gji" id="RBh-0O-yAN"/>
+                                            <outlet property="forwardButton" destination="F9L-PP-AbM" id="cc0-4F-r5v"/>
                                             <outlet property="labelCurrentTime" destination="kVv-X4-6SK" id="vyf-Bb-TPL"/>
                                             <outlet property="labelOverallDuration" destination="OUD-HH-cXH" id="E0O-99-aeq"/>
                                             <outlet property="muteButton" destination="8AB-hx-yqN" id="9zQ-k7-auv"/>
@@ -357,6 +385,8 @@
     </scenes>
     <resources>
         <image name="audioOn" width="28" height="28"/>
+        <image name="gobackward.15" catalog="system" width="121" height="128"/>
+        <image name="goforward.15" catalog="system" width="121" height="128"/>
         <image name="image" width="128" height="128"/>
         <image name="play.fill" catalog="system" width="116" height="128"/>
         <systemColor name="labelColor">

+ 36 - 9
iOSClient/Viewer/NCViewerVideo/NCViewerVideoToolBar.swift

@@ -27,11 +27,14 @@ class NCViewerVideoToolBar: UIView {
     
     @IBOutlet weak var playButton: UIButton!
     @IBOutlet weak var muteButton: UIButton!
+    @IBOutlet weak var forwardButton: UIButton!
+    @IBOutlet weak var backButton: UIButton!
     @IBOutlet weak var playbackSlider: UISlider!
     @IBOutlet weak var labelOverallDuration: UILabel!
     @IBOutlet weak var labelCurrentTime: UILabel!
     
     var player: AVPlayer?
+    fileprivate let seekDuration: Float64 = 15
     
     override func willMove(toWindow newWindow: UIWindow?) {
         super.willMove(toWindow: newWindow)
@@ -59,6 +62,7 @@ class NCViewerVideoToolBar: UIView {
         playbackSlider.minimumValue = 0
         playbackSlider.maximumValue = Float(durationSeconds)
         playbackSlider.isContinuous = true
+        playbackSlider.tintColor = .lightGray
         playbackSlider.action(for: .valueChanged) { _ in
             let seconds : Int64 = Int64(self.playbackSlider.value)
             let targetTime:CMTime = CMTimeMake(value: seconds, timescale: 1)
@@ -99,8 +103,13 @@ class NCViewerVideoToolBar: UIView {
         } else {
             muteButton.setImage(NCUtility.shared.loadImage(named: "audioOn", color: .white), for: .normal)
         }
+        
+        backButton.setImage(NCUtility.shared.loadImage(named: "gobackward.15", color: .white), for: .normal)
+        forwardButton.setImage(NCUtility.shared.loadImage(named: "goforward.15", color: .white), for: .normal)
     }
 
+    //MARK: - Action
+    
     @IBAction func playerPause(_ sender: Any) {
         
         if player?.timeControlStatus == .playing {
@@ -119,18 +128,36 @@ class NCViewerVideoToolBar: UIView {
         setToolBar()
     }
     
-    @objc func playbackSliderValueChanged(_ playbackSlider:UISlider) {
-           
-        let seconds : Int64 = Int64(playbackSlider.value)
-        let targetTime:CMTime = CMTimeMake(value: seconds, timescale: 1)
-           
-        player?.seek(to: targetTime)
-           
-        if player?.rate == 0 {
-            player?.play()
+    @IBAction func forwardButtonSec(_ sender: Any) {
+        guard let player = self.player else { return }
+        
+        if let duration = player.currentItem?.duration {
+            
+            let playerCurrentTime = CMTimeGetSeconds(player.currentTime())
+            let newTime = playerCurrentTime + seekDuration
+            if newTime < CMTimeGetSeconds(duration) {
+                let selectedTime: CMTime = CMTimeMake(value: Int64(newTime * 1000 as Float64), timescale: 1000)
+                player.seek(to: selectedTime)
+            }
+            player.pause()
+            player.play()
         }
     }
     
+    @IBAction func backButtonSec(_ sender: Any) {
+        guard let player = self.player else { return }
+
+        let playerCurrenTime = CMTimeGetSeconds(player.currentTime())
+        var newTime = playerCurrenTime - seekDuration
+        if newTime < 0 { newTime = 0 }
+        player.pause()
+        let selectedTime: CMTime = CMTimeMake(value: Int64(newTime * 1000 as Float64), timescale: 1000)
+        player.seek(to: selectedTime)
+        player.play()
+    }
+    
+    //MARK: - Algorithms
+    
     func stringFromTimeInterval(interval: TimeInterval) -> String {
     
         let interval = Int(interval)