Einzelnen Beitrag anzeigen

Peter666

Registriert seit: 11. Aug 2007
357 Beiträge
 
#1

Fairplay Apple

  Alt 31. Jul 2021, 22:34
Hi,

ich versuche gerade den Alcinoe Player unter IOS mit DRM Streams zu verwenden.
Soweit ich das ganze verstanden habe, muss ich ein AVURLAsset erstellen in dem ein Callback für die Ressource hinterlegt wird. Hat jemand ungefähr eine Idee wie ich das umsetzen kann? Der ObjectiveC Code schaut wie folgt aus.


Code:
- (void)loadPlayerView
{
    NSURL *url = [NSURL URLWithString:@"https://nyoba.innoplayer.co/cdn/videos/fairplay/muxed/encrypted/prog_index.m3u8"];
   
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil];
    [asset.resourceLoader setDelegate:self queue:dispatch_get_main_queue()];
   
    AVPlayer *player = [[AVPlayer alloc] initWithPlayerItem:[AVPlayerItem playerItemWithAsset:asset]];
   
    AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
    controller.player = player;
    [self presentViewController:controller animated:YES completion:nil];
}

- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest
{
    NSString *keyURL = @"https://nyoba.innoplayer.co/cdn/videos/fairplay/muxed/encrypted/Key.txt";
    NSURL *urlx = [NSURL URLWithString:keyURL];
   
    NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:urlx];
    [urlRequest setTimeoutInterval:20];
    [urlRequest setHTTPMethod:@"GET"];
   
    NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:urlRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
       
        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
        NSLog(@"requestHLSKeyWithURL httpResponse ==== %ld", (long)httpResponse.statusCode);
       
        if (data != nil && (httpResponse.statusCode == 200 || httpResponse.statusCode == 100))
        {
            NSLog(@"requestHLSKeyWithURL data ==== %@", data);
            [[loadingRequest contentInformationRequest] setContentType:AVStreamingKeyDeliveryPersistentContentKeyType];
            [[loadingRequest contentInformationRequest] setByteRangeAccessSupported:YES];
            [[loadingRequest contentInformationRequest] setContentLength:[data length]];
            [[loadingRequest dataRequest] respondWithData:data];
            [loadingRequest finishLoading];
        }
        else
        {
            NSLog(@"requestHLSKeyWithURL ==== NOT OK");
            [loadingRequest finishLoading];
        }
       
    }];
   
    [task resume];
   
    return YES;
}
Peter
  Mit Zitat antworten Zitat