How can I play FairPlay-encrypted audio on an AppleWatch with watchOS 5?

216 views Asked by At

watchOS 5 supports a new background audio mode so that audio apps (Audible, Overcast, etc) can play from the watch directly. I'm working on audio functionality for my app, but I have to use FairPlay DRM. I have segmented aac audio files with .m3u8 playlists, and I'm downloading them using AVAssetDownloadTask and do FairPlay key stuff with AVAssetResourceLoaderDelegate on the iPhone. And I'd like to add a watch app to play my content without the phone present.

But I don't see anything like this on the watch APIs. AVAssetResourceLoaderDelegate and AVContentKeySession aren't available on watchOS, and AVAudioPlayer doesn't take an AVAsset or seemingly any other way to do FairPlay key stuff (I use AVPlayer on the phone).

In the Creating Audio Apps for watchOS session at WWDC 2018, the presenter says:

And in the case of AVAudioEngine, you can actually play some DRM content in conjunction with AVAudioPlayer node. And so you can now play your own DRM content, decrypt it yourself, and play it back for your user.

But I haven't found anything yet about AVAudioEngine and FairPlay audio.

I've looked into AVAudioExportSession to try to transcode my FairPlay content to MP3 or AAC or M4A or something that I can transfer to the watch, but it doesn't think any formats are compatible:

AVAsset *asset = [self getDownloadedFairplayAsset];
NSArray<NSString *> *possible = [AVAssetExportSession exportPresetsCompatibleWithAsset:asset];

    for (NSString *preset in possible)
    {
        AVAssetExportSession *session = [AVAssetExportSession exportSessionWithAsset:asset presetName:preset];
        [session determineCompatibleFileTypesWithCompletionHandler:^(NSArray<AVFileType> * _Nonnull compatibleFileTypes) {
            NSLog(@"Compatible types with %@: %@", preset, compatibleFileTypes);
            //this is always an empty array
        }];
    }

So, my question: How can I play FairPlay-encrypted audio on a watchOS 5 app?

0

There are 0 answers