[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>
This commit is contained in:
parent
54b102f09e
commit
1c2ecc1c7c
5 changed files with 25 additions and 3 deletions
|
@ -187,6 +187,13 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
|
||||||
if(playbackStatus != CogStatusStopped && playbackStatus != CogStatusStopping)
|
if(playbackStatus != CogStatusStopped && playbackStatus != CogStatusStopping)
|
||||||
[self stop:self];
|
[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];
|
[[FIRCrashlytics crashlytics] logWithFormat:@"Playing track: %@", pe.url];
|
||||||
|
|
||||||
DLog(@"PLAYLIST CONTROLLER: %@", [playlistController class]);
|
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];
|
[[FIRCrashlytics crashlytics] logWithFormat:@"Beginning decoding track: %@", pe.url];
|
||||||
[player setNextStream:pe.url withUserInfo:pe withRGInfo:makeRGInfo(pe)];
|
[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 {
|
} else {
|
||||||
[[FIRCrashlytics crashlytics] log:@"End of playlist reached."];
|
[[FIRCrashlytics crashlytics] log:@"End of playlist reached."];
|
||||||
[player setNextStream:nil];
|
[player setNextStream:nil];
|
||||||
|
|
|
@ -484,7 +484,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path) {
|
||||||
- (void)setMetadata:(NSDictionary *)metadata {
|
- (void)setMetadata:(NSDictionary *)metadata {
|
||||||
if(metadata == nil) {
|
if(metadata == nil) {
|
||||||
self.error = YES;
|
self.error = YES;
|
||||||
self.errorMessage = @"Unable to retrieve metadata.";
|
self.errorMessage = NSLocalizedString(@"ErrorMetadata", @"");
|
||||||
} else {
|
} else {
|
||||||
self.volume = 1;
|
self.volume = 1;
|
||||||
[self setValuesForKeysWithDictionary:metadata];
|
[self setValuesForKeysWithDictionary:metadata];
|
||||||
|
|
|
@ -642,8 +642,12 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc
|
||||||
NSBlockOperation *op = [[NSBlockOperation alloc] init];
|
NSBlockOperation *op = [[NSBlockOperation alloc] init];
|
||||||
|
|
||||||
[op addExecutionBlock:^{
|
[op addExecutionBlock:^{
|
||||||
if(weakPe.deLeted) {
|
if(weakPe.deLeted || !weakPe.url) {
|
||||||
[weakLock lock];
|
[weakLock lock];
|
||||||
|
if(!weakPe.url) {
|
||||||
|
weakPe.error = YES;
|
||||||
|
weakPe.errorMessage = NSLocalizedString(@"ErrorMessageBadFile", @"");
|
||||||
|
}
|
||||||
progress += progressstep;
|
progress += progressstep;
|
||||||
[self setProgressJobStatus:progress];
|
[self setProgressJobStatus:progress];
|
||||||
[weakLock unlock];
|
[weakLock unlock];
|
||||||
|
|
|
@ -63,3 +63,6 @@
|
||||||
"ProgressActionLoadingMetadata" = "loading metadata for tracks";
|
"ProgressActionLoadingMetadata" = "loading metadata for tracks";
|
||||||
"ProgressSubActionLoadingMetadata" = "processing files";
|
"ProgressSubActionLoadingMetadata" = "processing files";
|
||||||
"ProgressSubActionMetadataApply" = "applying info to playlist storage";
|
"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";
|
"ProgressActionLoadingMetadata" = "loading metadata for tracks";
|
||||||
"ProgressSubActionLoadingMetadata" = "processing files";
|
"ProgressSubActionLoadingMetadata" = "processing files";
|
||||||
"ProgressSubActionMetadataApply" = "applying info to playlist storage";
|
"ProgressSubActionMetadataApply" = "applying info to playlist storage";
|
||||||
|
|
||||||
|
"ErrorMetadata" = "Unable to retrieve metadata.";
|
||||||
|
"ErrorMessageBadFile" = "Unable to parse metadata for bad file.";
|
||||||
|
|
Loading…
Reference in a new issue