Code:
class MyAssetResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate {
let certificateURL: URL
let licenseAcquisitionURL: URL
let contentId: String
init(certificateURL: URL, licenseAcquisitionURL: URL, contentId: String) {
[login to view URL] = certificateURL
[login to view URL] = licenseAcquisitionURL
[login to view URL] = contentId
}
public func resourceLoader(
_ resourceLoader: AVAssetResourceLoader,
shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest
) -> Bool {
print([login to view URL] ?? "no url")
// asdf
// We first check if a url is set in the manifest.
guard let url = [login to view URL] else {
print("?", #function, "Unable to read the url/host data.")
[login to view URL](with: NSError(domain: "[login to view URL]", code: -1, userInfo: nil))
return false
}
print("?", #function, url)
// When the url is correctly found we try to load the certificate date. Watch out! For this
// example the certificate resides inside the bundle. But it should be preferably fetched from
// the server.
guard let certificateData = try? Data(contentsOf: certificateURL) else {
[login to view URL](with: NSError(domain: "[login to view URL]", code: -2, userInfo: nil))
return false
}
// Request the Server Playback Context.
let usedContentId = [login to view URL] ?? "irdeto"
guard
let contentIdData = [login to view URL](using: [login to view URL]),
let spcData = try? [login to view URL](forApp: certificateData, contentIdentifier: contentIdData, options: nil),
let dataRequest = [login to view URL] else {
[login to view URL](with: NSError(domain: "[login to view URL]", code: -3, userInfo: nil))
print("?", #function, "Unable to read the SPC data.")
return false
}
// Request the Content Key Context from the Key Server Module.
let ckcURL = licenseAcquisitionURL
var request = URLRequest(url: ckcURL)
[login to view URL] = "POST"
[login to view URL] = spcData
let session = URLSession(configuration: [login to view URL])
let task = [login to view URL](with: request) { data, response, error in
if let data = data {
// The CKC is correctly returned and is now send to the `AVPlayer` instance so we
// can continue to play the stream.
[login to view URL](with: data)
[login to view URL]()
} else {
print("?", #function, "Unable to fetch the CKC.")
[login to view URL](with: NSError(domain: "[login to view URL]", code: -4, userInfo: nil))
}
}
[login to view URL]()
// asdf
return true
}
}
Hello, I have 5+years of experience in iPhone Application Development. I want always clients satisfied with my work. I am working as a full-time freelancer. Thanks