[Playlist] Handle invalid files in a better way
Invalid files may include nil URLs, which should be skipped or stop playback altogether. Invalid files will be marked as an error, and stop playback. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
54b102f09e
commit
1c2ecc1c7c
|
@ -187,6 +187,13 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
|
|||
if(playbackStatus != CogStatusStopped && playbackStatus != CogStatusStopping)
|
||||
[self stop:self];
|
||||
|
||||
if(!pe.url) {
|
||||
pe.error = YES;
|
||||
pe.errorMessage = NSLocalizedString(@"ErrorMessageBadFile", @"");
|
||||
[[FIRCrashlytics crashlytics] log:@"Attempting to play bad file."];
|
||||
return;
|
||||
}
|
||||
|
||||
[[FIRCrashlytics crashlytics] logWithFormat:@"Playing track: %@", pe.url];
|
||||
|
||||
DLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]);
|
||||
|
@ -577,9 +584,14 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
|
|||
}
|
||||
}
|
||||
|
||||
if(pe) {
|
||||
if(pe && pe.url) {
|
||||
[[FIRCrashlytics crashlytics] logWithFormat:@"Beginning decoding track: %@", pe.url];
|
||||
[player setNextStream:pe.url withUserInfo:pe withRGInfo:makeRGInfo(pe)];
|
||||
} else if(pe) {
|
||||
[[FIRCrashlytics crashlytics] log:@"Invalid playlist entry reached."];
|
||||
[player setNextStream:nil];
|
||||
pe.error = YES;
|
||||
pe.errorMessage = NSLocalizedString(@"ErrorMessageBadFile", @"");
|
||||
} else {
|
||||
[[FIRCrashlytics crashlytics] log:@"End of playlist reached."];
|
||||
[player setNextStream:nil];
|
||||
|
|
|
@ -484,7 +484,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
|
|||
- (void)setMetadata:(NSDictionary *)metadata {
|
||||
if(metadata == nil) {
|
||||
self.error = YES;
|
||||
self.errorMessage = @"Unable to retrieve metadata.";
|
||||
self.errorMessage = NSLocalizedString(@"ErrorMetadata", @"");
|
||||
} else {
|
||||
self.volume = 1;
|
||||
[self setValuesForKeysWithDictionary:metadata];
|
||||
|
|
|
@ -642,8 +642,12 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
|||
NSBlockOperation *op = [[NSBlockOperation alloc] init];
|
||||
|
||||
[op addExecutionBlock:^{
|
||||
if(weakPe.deLeted) {
|
||||
if(weakPe.deLeted || !weakPe.url) {
|
||||
[weakLock lock];
|
||||
if(!weakPe.url) {
|
||||
weakPe.error = YES;
|
||||
weakPe.errorMessage = NSLocalizedString(@"ErrorMessageBadFile", @"");
|
||||
}
|
||||
progress += progressstep;
|
||||
[self setProgressJobStatus:progress];
|
||||
[weakLock unlock];
|
||||
|
|
|
@ -63,3 +63,6 @@
|
|||
"ProgressActionLoadingMetadata" = "loading metadata for tracks";
|
||||
"ProgressSubActionLoadingMetadata" = "processing files";
|
||||
"ProgressSubActionMetadataApply" = "applying info to playlist storage";
|
||||
|
||||
"ErrorMetadata" = "Unable to retrieve metadata.";
|
||||
"ErrorMessageBadFile" = "Unable to parse metadata for bad file.";
|
||||
|
|
|
@ -63,3 +63,6 @@
|
|||
"ProgressActionLoadingMetadata" = "loading metadata for tracks";
|
||||
"ProgressSubActionLoadingMetadata" = "processing files";
|
||||
"ProgressSubActionMetadataApply" = "applying info to playlist storage";
|
||||
|
||||
"ErrorMetadata" = "Unable to retrieve metadata.";
|
||||
"ErrorMessageBadFile" = "Unable to parse metadata for bad file.";
|
||||
|
|
Loading…
Reference in New Issue