Here's how I use presentMediaPlayerControllerWithURL. I download a video from the internet and save it to ApplicationGroup. It does play on Simulator. However it doesn't play on real device. Anyone know if it's a bug?
p.s.: I can play video from NSBundle on real device.
NSURL * url = [NSURL URLWithString:jsonDic[@"video_url"]];
NSString * fileName = jsonDic[@"file_name"];
NSFileManager * manager = [NSFileManager defaultManager];
NSURL * directoryURL = [manager containerURLForSecurityApplicationGroupIdentifier:@"group.testing"];
NSURL * toURL = [directoryURL URLByAppendingPathComponent:fileName];
NSURLSessionDownloadTask * task = [[NSURLSession sharedSession] downloadTaskWithURL:url completionHandler:^(NSURL * __nullable location, NSURLResponse * __nullable response, NSError * __nullable error) {
if (error){
return;
}
[manager copyItemAtURL:location toURL:toURL error:nil];
[self presentMediaPlayerControllerWithURL: toURL
options:@{WKMediaPlayerControllerOptionsAutoplayKey : @YES}
completion:^(BOOL didPlayToEnd, NSTimeInterval endTime, NSError * __nullable error) {
if (error){
NSLog(error.localizedDescription);
}
}];
}];
[task resume];