瀏覽代碼

add preprocessor

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 年之前
父節點
當前提交
a2333c684e

+ 0 - 1
iOSClient/Brand/NCBrand.swift

@@ -92,7 +92,6 @@ import UIKit
 
     @objc public var disable_background_color:          Bool = true
     @objc public var disable_background_image:          Bool = true
-    @objc public var disable_ff:                        Bool = true
 
     override init() {
 

+ 33 - 1
iOSClient/Menu/NCViewer+Menu.swift

@@ -133,7 +133,39 @@ extension NCViewer {
                 )
             )
         }
-
+        
+        //
+        // CONVERSION VIDEO TO MPEG4 (MFFF Lib)
+        //
+        #if MFFF
+        if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue {
+            
+            actions.append(
+                NCMenuAction(
+                    title: NSLocalizedString("_video_conversion_", comment: ""),
+                    icon: NCUtility.shared.loadImage(named: "film"),
+                    action: { menuAction in
+                        
+                        let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+                        let urlOut = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: NCGlobal.shared.fileNameVideoEncoded))
+                        
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterPauseMedia)
+                        
+                        MFFF.shared.convertVideo(url: url, urlOut: urlOut, serverUrl: metadata.serverUrl, fileName: metadata.fileNameView, contentType: metadata.contentType, ocId: metadata.ocId) { url, returnCode in
+                            if returnCode?.isSuccess() ?? false {
+                                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadMediaPage)
+                            } else if returnCode?.isCancel() ?? false {
+                                print("cancel")
+                            } else {
+                                NCContentPresenter.shared.messageNotification("_error_", description: "_error_something_wrong_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
+                            }
+                        }
+                    }
+                )
+            )
+        }
+        #endif
+        
         //
         // SAVE IMAGE / VIDEO
         //

+ 29 - 24
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -79,41 +79,46 @@ class NCPlayer: NSObject {
                 }
                 break
             case .failed:
-                if error?.code == AVError.Code.fileFormatNotRecognized.rawValue && !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: NCGlobal.shared.fileNameVideoEncoded) && !NCBrandOptions.shared.disable_ff {
+                #if MFFF
+                if error?.code == AVError.Code.fileFormatNotRecognized.rawValue {
                     let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: NSLocalizedString("_video_format_not_recognized_", comment: ""), preferredStyle: .alert)
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
-                        /*
-                        ncFF.convertVideo { session, url in
-                            let returnCode = session?.getReturnCode()
-                             
-                            if returnCode?.isSuccess() ?? false {
-                                 self.url = url
-                                 self.openAVPlayer() { status, error in
-                                     if let error = error {
-                                         NCContentPresenter.shared.messageNotification(error.localizedDescription, description: error.localizedFailureReason, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
-                                     }
-                                 }
-                             } else if returnCode?.isCancel() ?? false {
-                                // nothing
-                             } else {
-                                 NCContentPresenter.shared.messageNotification("_error_", description: "_error_something_wrong_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
+                        
+                        let url = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView))
+                        let urlOut = URL(fileURLWithPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: NCGlobal.shared.fileNameVideoEncoded))
+                        
+                        MFFF.shared.convertVideo(url: url, urlOut: urlOut, serverUrl: self.metadata.serverUrl, fileName: self.metadata.fileNameView, contentType: self.metadata.contentType, ocId: metadata.ocId) { url, returnCode in
+                            if returnCode?.isSuccess() ?? false, let url = url {
+                                self.url = url
+                                self.openAVPlayer() { status, error in
+                                    if let error = error {
+                                        NCContentPresenter.shared.messageNotification(error.localizedDescription, description: error.localizedFailureReason, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
+                                    }
+                                }
+                            } else if returnCode?.isCancel() ?? false {
+                                print("cancel")
+                            } else {
+                                NCContentPresenter.shared.messageNotification("_error_", description: "_error_something_wrong_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
                             }
-                         }
-                         */
+                        }
                     }))
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { action in
                         NCContentPresenter.shared.messageNotification("_info_", description: "_video_conversion_available_after_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorNoError, priority: .max)
                     }))
                     self.appDelegate.window?.rootViewController?.present(alertController, animated: true)
+                } else if let title = error?.localizedDescription, let description = error?.localizedFailureReason {
+                    NCContentPresenter.shared.messageNotification(title, description: description, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
                 } else {
-                    if let title = error?.localizedDescription, let description = error?.localizedFailureReason {
-                        NCContentPresenter.shared.messageNotification(title, description: description, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
-                    } else {
-                        NCContentPresenter.shared.messageNotification("_error_", description: "_error_something_wrong_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
-                    }
+                    NCContentPresenter.shared.messageNotification("_error_", description: "_error_something_wrong_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
+                }
+                #else
+                if let title = error?.localizedDescription, let description = error?.localizedFailureReason {
+                    NCContentPresenter.shared.messageNotification(title, description: description, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
+                } else {
+                    NCContentPresenter.shared.messageNotification("_error_", description: "_error_something_wrong_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorGeneric, priority: .max)
                 }
+                #endif
                 break
-                
             case .cancelled:
                 break
             default: