marinofaggiana 3 years ago
parent
commit
2de72458ca

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -1212,9 +1212,9 @@
 		F79EDA9E26B004980007D134 /* NCViewerVideo */ = {
 			isa = PBXGroup;
 			children = (
-				F716B75E26F09DF600D37EFC /* NCKTVHTTPCache.swift */,
-				F79EDA9F26B004980007D134 /* NCViewerVideoToolBar.swift */,
 				F79EDAA126B004980007D134 /* NCViewerVideo.swift */,
+				F79EDA9F26B004980007D134 /* NCViewerVideoToolBar.swift */,
+				F716B75E26F09DF600D37EFC /* NCKTVHTTPCache.swift */,
 			);
 			path = NCViewerVideo;
 			sourceTree = "<group>";

+ 12 - 0
iOSClient/Images.xcassets/gobackward.15.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "gobackward.15.svg",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 4 - 0
iOSClient/Images.xcassets/gobackward.15.imageset/gobackward.15.svg

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.1" width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+  <path d="M 13.5 3 C 8.529 3 4.5 7.029 4.5 12 L 1.5 12 L 5.5 16 L 9.5 12 L 6.5 12 C 6.5 8.134 9.634 5 13.5 5 C 17.366 5 20.5 8.134 20.5 12 C 20.5 15.866 17.366 19 13.5 19 C 12 19 10.59 18.5 9.44 17.7 L 8 19.14 C 9.54 20.3 11.44 21 13.5 21 C 18.471 21 22.5 16.971 22.5 12 C 22.5 7.029 18.471 3 13.5 3 M 15.5 12 C 15.5 10.895 14.605 10 13.5 10 C 12.395 10 11.5 10.895 11.5 12 C 11.5 13.105 12.395 14 13.5 14 C 14.605 14 15.5 13.105 15.5 12 Z"/>
+</svg>

+ 12 - 0
iOSClient/Images.xcassets/goforward.15.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "goforward.15.svg",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 4 - 0
iOSClient/Images.xcassets/goforward.15.imageset/goforward.15.svg

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.1" width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+  <path d="M 13.5 21 C 8.529 21 4.5 16.971 4.5 12 L 1.5 12 L 5.5 8 L 9.5 12 L 6.5 12 C 6.5 15.866 9.634 19 13.5 19 C 17.366 19 20.5 15.866 20.5 12 C 20.5 8.134 17.366 5 13.5 5 C 12 5 10.59 5.5 9.44 6.3 L 8 4.86 C 9.54 3.7 11.44 3 13.5 3 C 18.471 3 22.5 7.029 22.5 12 C 22.5 16.971 18.471 21 13.5 21 M 15.5 12 C 15.5 13.105 14.605 14 13.5 14 C 12.395 14 11.5 13.105 11.5 12 C 11.5 10.895 12.395 10 13.5 10 C 14.605 10 15.5 10.895 15.5 12 Z" transform="matrix(-1, 0, 0, -1, 24, 24)"/>
+</svg>

+ 12 - 9
iOSClient/Viewer/NCViewerImage/NCViewerImage.storyboard

@@ -4,6 +4,7 @@
     <dependencies>
         <deployment identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
+        <capability name="Image references" minToolsVersion="12.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -235,7 +236,7 @@
                                                 <rect key="frame" x="0.0" y="0.0" width="364" height="100"/>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8AB-hx-yqN">
-                                                <rect key="frame" x="328.99999999999994" y="65" width="25" height="25"/>
+                                                <rect key="frame" x="328.99999999999994" y="67.666666666666629" width="25" height="25"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="25" id="6yU-23-dkA"/>
                                                     <constraint firstAttribute="height" constant="25" id="hBk-Ku-BAd"/>
@@ -250,13 +251,15 @@
                                                 <rect key="frame" x="8" y="15" width="348" height="31"/>
                                             </slider>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="x3E-b2-obf">
-                                                <rect key="frame" x="167" y="60" width="30" height="30"/>
+                                                <rect key="frame" x="162" y="60" width="40" height="40"/>
                                                 <constraints>
-                                                    <constraint firstAttribute="width" constant="30" id="Cmv-LX-Phg"/>
-                                                    <constraint firstAttribute="height" constant="30" id="djE-Ml-YD0"/>
+                                                    <constraint firstAttribute="width" constant="40" id="Cmv-LX-Phg"/>
+                                                    <constraint firstAttribute="height" constant="40" id="djE-Ml-YD0"/>
                                                 </constraints>
                                                 <color key="tintColor" systemColor="labelColor"/>
-                                                <state key="normal" image="play.fill" catalog="system"/>
+                                                <state key="normal">
+                                                    <imageReference key="image" image="play.fill" catalog="system" symbolScale="default"/>
+                                                </state>
                                                 <connections>
                                                     <action selector="playerPause:" destination="sBp-t2-eFh" eventType="touchUpInside" id="pRl-bT-hpi"/>
                                                 </connections>
@@ -274,7 +277,7 @@
                                                 <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="246.99999999999994" y="62.666666666666629" width="25" height="25"/>
+                                                <rect key="frame" x="251.99999999999994" y="67.666666666666629" width="25" height="25"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="25" id="hlL-XQ-OLa"/>
                                                     <constraint firstAttribute="height" constant="25" id="vEe-Fb-a9N"/>
@@ -285,7 +288,7 @@
                                                 </connections>
                                             </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Isy-sX-Gji">
-                                                <rect key="frame" x="92" y="62.666666666666629" width="25" height="25"/>
+                                                <rect key="frame" x="87" y="67.666666666666629" width="25" height="25"/>
                                                 <constraints>
                                                     <constraint firstAttribute="width" constant="25" id="COm-r2-ubw"/>
                                                     <constraint firstAttribute="height" constant="25" id="mbb-ql-zCc"/>
@@ -299,8 +302,7 @@
                                         <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 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="bottom" secondItem="x3E-b2-obf" secondAttribute="bottom" id="7W8-qk-uwn"/>
                                             <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="a0D-B0-eGX" firstAttribute="leading" secondItem="sBp-t2-eFh" secondAttribute="leading" id="OIL-1t-uuh"/>
@@ -313,6 +315,7 @@
                                             <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 firstAttribute="trailing" secondItem="a0D-B0-eGX" secondAttribute="trailing" id="lbh-DN-SZF"/>
+                                            <constraint firstItem="8AB-hx-yqN" firstAttribute="centerY" secondItem="F9L-PP-AbM" secondAttribute="centerY" id="o5E-tm-osC"/>
                                             <constraint firstItem="x3E-b2-obf" firstAttribute="leading" secondItem="Isy-sX-Gji" secondAttribute="trailing" constant="50" id="sIc-bL-Yjz"/>
                                             <constraint firstItem="x3E-b2-obf" firstAttribute="centerX" secondItem="sBp-t2-eFh" secondAttribute="centerX" id="uPa-tM-Vx6"/>
                                             <constraint firstItem="SR4-e8-1hC" firstAttribute="top" secondItem="sBp-t2-eFh" secondAttribute="top" constant="15" id="uu1-ai-wmJ"/>

+ 3 - 3
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -264,7 +264,7 @@ class NCViewerImage: UIViewController {
                 if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
                     
                     AudioServicesPlaySystemSound(1519) // peek feedback
-                    NCViewerVideo.shared.videoPlay(view: self.currentViewerImageZoom?.imageView, viewerVideoToolBar: nil, metadata: metadata)
+                    NCViewerVideo.shared.videoPlay(imageView: self.currentViewerImageZoom?.imageView, viewerVideoToolBar: nil, metadata: metadata)
                     
                 } else {
                     
@@ -289,7 +289,7 @@ class NCViewerImage: UIViewController {
                             
                             if gestureRecognizer.state == .changed || gestureRecognizer.state == .began {
                                 AudioServicesPlaySystemSound(1519) // peek feedback
-                                NCViewerVideo.shared.videoPlay(view: self.currentViewerImageZoom?.imageView, viewerVideoToolBar: nil, metadata: metadata)
+                                NCViewerVideo.shared.videoPlay(imageView: self.currentViewerImageZoom?.imageView, viewerVideoToolBar: nil, metadata: metadata)
                             }
                         }
                     }
@@ -599,7 +599,7 @@ extension NCViewerImage: NCViewerImageZoomDelegate {
         // PLAY VIDEO/AUDIO
         if (currentMetadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || currentMetadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue) {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
-                NCViewerVideo.shared.videoPlay(view: viewerImageZoom.imageView, viewerVideoToolBar: viewerImageZoom.videoToolBar, metadata: metadata)
+                NCViewerVideo.shared.videoPlay(imageView: viewerImageZoom.imageView, viewerVideoToolBar: viewerImageZoom.videoToolBar, metadata: metadata)
             }
         }
             

+ 2 - 0
iOSClient/Viewer/NCViewerImage/NCViewerImageZoom.swift

@@ -122,7 +122,9 @@ class NCViewerImageZoom: UIViewController {
         coordinator.animate(alongsideTransition: { (context) in
             self.view.layoutIfNeeded()
             UIView.animate(withDuration: context.transitionDuration) {
+                // resize frame video
                 NCViewerVideo.shared.videoLayer?.frame = self.imageView.layer.bounds
+                // resize detail
                 if self.detailView.isShow() {
                     self.openDetail()
                 }

+ 6 - 17
iOSClient/Viewer/NCViewerVideo/NCViewerVideo.swift

@@ -32,7 +32,7 @@ class NCViewerVideo: NSObject {
     }()
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    private var view: UIView?
+    private var imageView: UIImageView?
     private var timeObserver: Any?
     private var rateObserver: Any?
     private var metadata: tableMetadata?
@@ -40,8 +40,6 @@ class NCViewerVideo: NSObject {
     public var videoLayer: AVPlayerLayer?
     public var player: AVPlayer?
     public var viewerVideoToolBar: NCViewerVideoToolBar?
-    public var pictureInPictureOcId: String = ""
-    
     
     //MARK: - NotificationCenter
 
@@ -52,10 +50,10 @@ class NCViewerVideo: NSObject {
         }
     }
     
-    func videoPlay(view: UIView?, viewerVideoToolBar: NCViewerVideoToolBar?, metadata: tableMetadata) {
-        guard let view = view else { return }
+    func videoPlay(imageView: UIImageView?, viewerVideoToolBar: NCViewerVideoToolBar?, metadata: tableMetadata) {
+        guard let imageView = imageView else { return }
         
-        self.view = view
+        self.imageView = imageView
         self.viewerVideoToolBar = viewerVideoToolBar
         self.metadata = metadata
         
@@ -66,20 +64,11 @@ class NCViewerVideo: NSObject {
             self.player = AVPlayer(url: url)
             self.player?.isMuted = CCUtility.getAudioMute()
             self.videoLayer = AVPlayerLayer(player: self.player)
-            self.videoLayer!.frame = view.bounds
+            self.videoLayer!.frame = imageView.bounds
             self.videoLayer!.videoGravity = .resizeAspect
             
-            view.layer.addSublayer(videoLayer!)
+            imageView.layer.addSublayer(videoLayer!)
 
-            /*
-            NSLayoutConstraint.activate([
-                view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
-                videoLayer.topAnchor.constraint(equalTo: view.topAnchor),
-                videoLayer.widthAnchor.constraint(equalToConstant: view.width),
-                videoLayer.heightAnchor.constraint(equalToConstant: view.height)
-            ])
-            */
-            
             // At end go back to start & show toolbar
             NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: self.player?.currentItem, queue: .main) { (notification) in
                 if let item = notification.object as? AVPlayerItem, let currentItem = self.player?.currentItem, item == currentItem {

+ 7 - 0
iOSClient/Viewer/NCViewerVideo/NCViewerVideoToolBar.swift

@@ -76,6 +76,13 @@ class NCViewerVideoToolBar: UIView {
         labelOverallDuration.text = stringFromTimeInterval(interval: 0)
         labelOverallDuration.textColor = .lightGray
         
+        if #available(iOS 13.0, *) {
+            let config = UIImage.SymbolConfiguration(scale: .large)
+            playButton.setImage(NCUtility.shared.loadImage(named: "play.fill", color: .white, symbolConfiguration: config), for: .normal)
+        } else {
+            playButton.setImage(NCUtility.shared.loadImage(named: "play.fill", 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)