浏览代码

Update NCPlayer.swift

Marino Faggiana 1 年之前
父节点
当前提交
284b6a8386
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

+ 5 - 4
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -377,22 +377,23 @@ extension NCPlayer: VLCMediaThumbnailerDelegate {
 
     func mediaThumbnailer(_ mediaThumbnailer: VLCMediaThumbnailer, didFinishThumbnail thumbnail: CGImage) {
 
-        let image = UIImage(cgImage: thumbnail)
+        var image: UIImage?
 
         do {
+            image = UIImage(cgImage: thumbnail)
             // Update Playing Info Center
             let mediaItemPropertyTitle = MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyTitle] as? String
-            if mediaItemPropertyTitle == metadata.fileNameView {
+            if let image = image, mediaItemPropertyTitle == metadata.fileNameView {
                 MPNowPlayingInfoCenter.default().nowPlayingInfo?[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size) { _ in
                     return image
                 }
             }
             // Preview
-            if let data = image.jpegData(compressionQuality: 0.5) {
+            if let data = image?.jpegData(compressionQuality: 0.5) {
                 try data.write(to: URL(fileURLWithPath: fileNamePreviewLocalPath), options: .atomic)
             }
             // Icon
-            if let data = image.jpegData(compressionQuality: 0.5) {
+            if let data = image?.jpegData(compressionQuality: 0.5) {
                 try data.write(to: URL(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
             }
         } catch let error as NSError {