marinofaggiana 4 жил өмнө
parent
commit
67b2e0212a

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -147,6 +147,7 @@
 "_automatic_Download_Image_footer_" = "When viewing images always download, if not available locally, the images in full resolution";
 "_size_"                    = "Size";
 "_dim_"                     = "Dimensions";
+"_duration_"                = "Duration";
 
 // App
 

+ 2 - 17
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -397,25 +397,10 @@ class NCViewerImage: UIViewController {
     //MARK: - Video
     
     func videoPlay(metadata: tableMetadata) {
-                
-        var videoURL: URL?
-                
+                                
         NCKTVHTTPCache.shared.startProxy(user: appDelegate.user, password: appDelegate.password, metadata: metadata)
 
-        if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-            
-            videoURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-            
-        } else {
-            
-            guard let stringURL = (metadata.serverUrl + "/" + metadata.fileName).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
-                return
-            }
-            
-            videoURL = NCKTVHTTPCache.shared.getProxyURL(stringURL: stringURL)
-        }
-        
-        if let url = videoURL {
+        if let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata) {
             
             player = AVPlayer(url: url)
             player?.isMuted = CCUtility.getAudioMute()

+ 5 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImageDetailView.swift

@@ -137,12 +137,16 @@ class NCViewerImageDetailView: UIView {
             dateValue.text = dateString + ", " + timeString
         }
         
-        // Dimensions
+        // Dimensions / Durations
         if metadata?.typeFile == k_metadataTypeFile_image {
             if let image = self.image {
                 dimLabel.text = NSLocalizedString("_dim_", comment: "")
                 dimValue.text = "\(Int(image.size.width)) x \(Int(image.size.height))"
             }
+        } else if metadata?.typeFile == k_metadataTypeFile_video {
+            if let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata!) {
+                
+            }
         }
         
         // Map

+ 14 - 0
iOSClient/Viewer/NCViewerVideo/NCKTVHTTPCache.swift

@@ -31,6 +31,20 @@ class NCKTVHTTPCache: NSObject {
         return instance
     }()
     
+    func getVideoURL(metadata: tableMetadata) -> URL? {
+        
+        if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
+            
+            return URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+            
+        } else {
+            
+            guard let stringURL = (metadata.serverUrl + "/" + metadata.fileName).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { return nil }
+            
+            return NCKTVHTTPCache.shared.getProxyURL(stringURL: stringURL)
+        }
+    }
+    
     func startProxy(user: String, password: String, metadata: tableMetadata) {
         
         guard let authData = (user + ":" + password).data(using: .utf8) else { return }

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

@@ -47,25 +47,9 @@ protocol NCViewerVideoDelegate {
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
         
-        var videoURL: URL?
-
         NCKTVHTTPCache.shared.startProxy(user: appDelegate.user, password: appDelegate.password, metadata: metadata)
         
-        if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
-            
-            videoURL = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
-            
-        } else {
-            
-            guard let stringURL = (metadata.serverUrl + "/" + metadata.fileName).addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
-                return
-            }
-            
-            allowsPictureInPicturePlayback = false
-            videoURL = NCKTVHTTPCache.shared.getProxyURL(stringURL: stringURL)
-        }
-        
-        if let url = videoURL {
+        if let url = NCKTVHTTPCache.shared.getVideoURL(metadata: metadata) {
             
             player = AVPlayer(url: url)