Commit f2095690 authored by Felix Paul Kühne's avatar Felix Paul Kühne

library view controller: return early and don't set the activity if MLKit...

library view controller: return early and don't set the activity if MLKit fails to provide a media URI description

(cherry picked from commit d43effa9)
parent e24e1d65
...@@ -353,6 +353,11 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -353,6 +353,11 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
- (void)createSpotlightItem:(nonnull NSManagedObject *)mediaObject - (void)createSpotlightItem:(nonnull NSManagedObject *)mediaObject
{ {
if (![VLCKeychainCoordinator passcodeLockEnabled]) { if (![VLCKeychainCoordinator passcodeLockEnabled]) {
NSURL *uriRepresentation = mediaObject.objectID.URIRepresentation;
if (uriRepresentation == nil) {
return;
}
self.userActivity = [[NSUserActivity alloc] initWithActivityType:kVLCUserActivityPlaying]; self.userActivity = [[NSUserActivity alloc] initWithActivityType:kVLCUserActivityPlaying];
MLFile *file = nil; MLFile *file = nil;
...@@ -363,14 +368,10 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -363,14 +368,10 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
} else if ([mediaObject isKindOfClass:[MLFile class]]){ } else if ([mediaObject isKindOfClass:[MLFile class]]){
file = (MLFile *)mediaObject; file = (MLFile *)mediaObject;
} }
self.userActivity.title = file.title; self.userActivity.title = file.title;
self.userActivity.contentAttributeSet = file.coreSpotlightAttributeSet; self.userActivity.contentAttributeSet = file.coreSpotlightAttributeSet;
self.userActivity.userInfo = @{ @"playingmedia": uriRepresentation};
NSURL *uriRepresentation = mediaObject.objectID.URIRepresentation;
if (uriRepresentation != nil) {
self.userActivity.userInfo = @{ @"playingmedia": uriRepresentation};
}
self.userActivity.eligibleForSearch = YES; self.userActivity.eligibleForSearch = YES;
self.userActivity.eligibleForHandoff = YES; self.userActivity.eligibleForHandoff = YES;
[self.userActivity becomeCurrent]; [self.userActivity becomeCurrent];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment