Playing AES encrypted hls stream using avplayer - ios swift
<p>i'm trying to play an AES encrypted stream in AVPlayer.. typically a link of the key is delivered to the player inside the M3U8 playlist.. in my scenario the key is divided in half.. the first half is delivered by the server and i should append the other half inside the app to decrypt when playing</p>

<p>i've already done this on Android, is there a way to do it also on iOS?</p>

<p>This is the playlist:
<b></p>

<pre><code>#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=200000,RESOLUTION=284x160
chunklist_w670540365_b200000.m3u8?t=57b5b16d3824d
#EXT-X-STREAM-INF:BANDWIDTH=850000,RESOLUTION=640x360
chunklist_w670540365_b850000.m3u8?t=57b5b16d3824d
</code></pre>

<p></b>
And this is the chunk list:</p>

<p><b></p>

<pre><code>#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:13544
#EXT-X-KEY:METHOD=AES-128,URI="http://example.com/api/getEncryptionKey?t=57b5b16d3824d"
#EXTINF:9.6,
media_w670540365_b200000_13544.ts?t=57b5b16d3824d
#EXTINF:9.6,
media_w670540365_b200000_13545.ts?t=57b5b16d3824d
#EXTINF:10.56,
media_w670540365_b200000_13546.ts?t=57b5b16d3824d
</code></pre>

<p></b></p>

<p>This is what AVPlayer does:</p>

<p>1- the playlist gets downloaded and a chunk list is selected
2- the player downloads the chunk list
3- the decryption key to decrypt the chunks is downloaded
4- the player begins downloading the chunks sequentially to play them 
5- every chunk is decrypted and played</p>

<p>What i need to do is:
after the 3rd step when the player calls the api to get the encryption key using this link: '<a href="http://example.com/api/getEncryptionKey?t=57b5b16d3824d" rel="noreferrer">http://example.com/api/getEncryptionKey?t=57b5b16d3824d</a>', i want to intercept the response and append the other half of the key</p>

<p>Is it possible?</p>