Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play a AES-128 encrypted HLS video in AVPlayer

I'm able to play a normal HLS video in AV Player without any trouble. But how do I play a AES-128 encrypted HLS Video?

like image 939
Shob-Z Avatar asked May 04 '17 13:05

Shob-Z


1 Answers

To decode an AES-128/similar encrypted HLS Video, just add 'Authorization' to your header.

let headers = ["Authorization": "Bearer xxxxxxxxxxxxxxxx..."]
let avAsset = AVURLAsset(url: videoURL, options: ["AVURLAssetHTTPHeaderFieldsKey": headers])
let avItem = AVPlayerItem(asset: avAsset)
let avPlayer = AVPlayer(playerItem: avItem)
.
.
.

Thanks @SeanLintern88 for helping me out on this.

like image 191
Shob-Z Avatar answered Nov 15 '22 02:11

Shob-Z