Question

I have an issue where I get EXC_BAD_ACCESS deep in URLConnectionClient when playing encrypted HLS assets and the encryption key goes missing. MPMovieViewController has no problem, it just fails to play, but as I mention, I get a crash when AVPlayer can't retrieve the decryption keys.

For instance this:

    AVPlayer *player = [[AVPlayer alloc] initWithURL:
        [NSURL URLWithString:@"http://192.168.1.69/prog_index.m3u8"]];

Will crash in a separate thread (com.apple.coremedia.networkbuffering to be specific), if the file prog_index.m3u8 is encrypted and the decryption key is unavailable. I have verified that it works fine when the decryption key can be loaded.

Does anyone know of a workaround?

Was it helpful?

Solution

This bug has been reported to Apple.

A workaround would be to load and parse the .m3u8-file and load the related decryption keys. If an error occurs, it's easy to handle that gracefully.

Store the downloaded decryption keys locally on the phone and replace the remote URL in the .m3u8 file with the local paths.

Finally, store the modified .m3u8 locally and feed that local URL to AVPlayer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top