浏览代码

Fix crash

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 年之前
父节点
当前提交
d9fd862608

+ 15 - 11
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift

@@ -144,20 +144,24 @@ class NCPlayerToolBar: UIView {
         guard let ncplayer = self.ncplayer else { return }
                 
         // MUTE
-        if CCUtility.getAudioMute() {
-            muteButton.setImage(NCUtility.shared.loadImage(named: "audioOff", color: .white), for: .normal)
-        } else {
-            muteButton.setImage(NCUtility.shared.loadImage(named: "audioOn", color: .white), for: .normal)
+        if let muteButton = muteButton {
+            if CCUtility.getAudioMute() {
+                muteButton.setImage(NCUtility.shared.loadImage(named: "audioOff", color: .white), for: .normal)
+            } else {
+                muteButton.setImage(NCUtility.shared.loadImage(named: "audioOn", color: .white), for: .normal)
+            }
+            muteButton.isEnabled = true
         }
-        muteButton.isEnabled = true
         
         // PIP
-        if metadata?.classFile == NCCommunicationCommon.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
+        if let pipButton = pipButton {
+            if metadata?.classFile == NCCommunicationCommon.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)

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

@@ -199,7 +199,7 @@ class NCViewerMedia: UIViewController {
                 etagResource = metadata.etagResource
             }
                
-            NCUtility.shared.startActivityIndicator(backgroundView: nil, blurEffect: false, bottom: 50, style: .gray)
+            DispatchQueue.main.async { NCUtility.shared.startActivityIndicator(backgroundView: self.viewerMediaPage?.view, blurEffect: false, bottom: 50, style: .gray) }
 
             NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNamePreviewLocalPath: fileNamePreviewLocalPath , widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource, queue: NCCommunicationCommon.shared.backgroundQueue) { (account, imagePreview, imageIcon, imageOriginal, etag, errorCode, errorDescription) in
                      
@@ -230,7 +230,7 @@ class NCViewerMedia: UIViewController {
             
             if (CCUtility.getAutomaticDownloadImage() || (metadata.contentType == "image/heic" &&  metadata.hasPreview == false) || ext == "GIF" || ext == "SVG" || isFolderEncrypted) && (metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue && !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) && metadata.session == "") {
                 
-                NCUtility.shared.startActivityIndicator(backgroundView: nil, blurEffect: false, bottom: 50, style: .gray)
+                DispatchQueue.main.async { NCUtility.shared.startActivityIndicator(backgroundView: self.viewerMediaPage?.view, blurEffect: false, bottom: 50, style: .gray) }
 
                 NCNetworking.shared.download(metadata: metadata, selector: "") { (_) in
                     
@@ -256,7 +256,7 @@ class NCViewerMedia: UIViewController {
 
             if let metadata = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", metadata.account, metadata.serverUrl, fileName)), !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
 
-                NCUtility.shared.startActivityIndicator(backgroundView: nil, blurEffect: false, bottom: 50, style: .gray)
+                DispatchQueue.main.async { NCUtility.shared.startActivityIndicator(backgroundView: self.viewerMediaPage?.view, blurEffect: false, bottom: 50, style: .gray) }
 
                 NCNetworking.shared.download(metadata: metadata, selector: "") { (_) in
                     NCUtility.shared.stopActivityIndicator()