Ver código fonte

VLCPlaybackController: Call saveVideoSnapshotAt only when the media have a video output

Signed-off-by: Carola Nitz <nitz.carola@googlemail.com>
Soomin Lee 7 anos atrás
pai
commit
6c93beb9ff
1 arquivos alterados com 13 adições e 12 exclusões
  1. 13 12
      Sources/VLCPlaybackController.m

+ 13 - 12
Sources/VLCPlaybackController.m

@@ -343,18 +343,19 @@ VLCMediaDelegate, VLCRemoteControlServiceDelegate>
         if (position > .95)
             return;
 
-        NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-        NSString* newThumbnailPath = [searchPaths[0] stringByAppendingPathComponent:@"VideoSnapshots"];
-        NSFileManager *fileManager = [NSFileManager defaultManager];
-
-        if (![fileManager fileExistsAtPath:newThumbnailPath])
-            [fileManager createDirectoryAtPath:newThumbnailPath withIntermediateDirectories:YES attributes:nil error:nil];
-
-        newThumbnailPath = [newThumbnailPath stringByAppendingPathComponent:fileItem.objectID.URIRepresentation.lastPathComponent];
-        [_mediaPlayer saveVideoSnapshotAt:newThumbnailPath withWidth:0 andHeight:0];
-
-        _recheckForExistingThumbnail = YES;
-        [self performSelector:@selector(_updateStoredThumbnailForFile:) withObject:fileItem afterDelay:.25];
+        if (_mediaPlayer.hasVideoOut) {
+            NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+            NSString *newThumbnailPath = [searchPaths.firstObject stringByAppendingPathComponent:@"VideoSnapshots"];
+            NSError *error;
+
+            [[NSFileManager defaultManager] createDirectoryAtPath:newThumbnailPath withIntermediateDirectories:YES attributes:nil error:&error];
+            if (error == nil) {
+                newThumbnailPath = [newThumbnailPath stringByAppendingPathComponent:fileItem.objectID.URIRepresentation.lastPathComponent];
+                [_mediaPlayer saveVideoSnapshotAt:newThumbnailPath withWidth:0 andHeight:0];
+                _recheckForExistingThumbnail = YES;
+                [self performSelector:@selector(_updateStoredThumbnailForFile:) withObject:fileItem afterDelay:.25];
+            }
+        }
     }
     @catch (NSException *exception) {
         APLog(@"failed to save current media state - file removed?");