Rahul Verma
Rahul Verma

Reputation: 684

AVAssetResourceLoaderDelegate methods override loadingRequest

While playing a decrypted HLS video i am using GCDServer to host m3u8 file and it played well when i am using a decrypted set of chunks in m3u8 file but when i used the decrypted one and tried to decrypt the key and chunks it is not playing there. As the AVAssetResourceLoaderDelegate methods not called with http scheme and if i use custom scheme then the GCDServer finished loading. Any suggestion?

  1. Can we override the loading request back to http? if yes then how.
  2. How to get content of m3u8 file and .key file from saved section, Here i would like to notify you that the NSBundle.mainBundle is not working for .key, m3u8, m3u and other playlist files.

trying something but not succeeded.

  let urlComponents = NSURLComponents(url: loadingRequest.request.url!, resolvingAgainstBaseURL: false)
    urlComponents?.scheme = "http"
    var mutableLoadingRequest = loadingRequest.request
    mutableLoadingRequest.url = urlComponents?.url
    loadingRequest.request = mutableLoadingRequest

This is what m getting in server log.

[DEBUG] Did open IPv4 listening socket 5

[DEBUG] Did open IPv6 listening socket 7 [INFO] GCDWebServer started on port 8080 and reachable at http://192.168.1.183:8080/ Get host url Optional(http://192.168.1.183:8080/) { URL: tapow://192.168.1.183:8080/ }, request ID = 1, content information request = , data request = >

Upvotes: 2

Views: 672

Answers (1)

Rahul Verma
Rahul Verma

Reputation: 684

Just want to share the answer in case anyone is in need,

  1. Can we override the loading request back to http? if yes then how.

Yes, we can. As the m3u8 is searching for the file in his own folder so just decrypt the m3u8 data in AVAssetResourceLoaderDelegate and return back to method then it will automatically perform the next task. P.S - you can replace it with other server ts too i just used it to for online streaming.

  1. How to get content of m3u8 file and .key file from saved section, Here i would like to notify you that the NSBundle.mainBundle is not working for .key, m3u8, m3u and other playlist files.

It is true that you can't get the reference of m3u8 in a variable in iOS but you can pass the object directly to required place. I have used GCDserver to host the m3u8 file and i just sent the local path url of m3u8 file in parameter and then GCDserver did its job and host the file on local server. Later i used the gcdserver url for avplayer.

Upvotes: 1

Related Questions