Post

Replies

Boosts

Views

Activity

Reply to AVAssetResourceLoaderDelegate and error handling
We were seeing some rare cases of sudden drift on live streams, where content would appear to be playing normally, and then we would suddenly see the audio and video be minutes apart from each other. This appeared to be related to HTTP 503 and 304 responses from the CDN on .m3u8 playlists. This issue didn’t happen on a brand new project, using an AVPlayer without a resource loader delegate, so we suspected that our own handling of these responses in our own AVAssetResourceLoaderDelegate could be the cause. We changed our code to the following, to handle the case of the 503s and other codes within the 400s-500s ranges. This did seem to solve the issue, but we weren't 100% certain if this was the right approach. Based on your answer, it sounds like we should just pass the HTTP code in directly instead of the "code: NSURLErrorBadServerResponse". loadingRequest.finishLoading( with: NSError( domain: NSURLErrorDomain, code: NSURLErrorBadServerResponse, userInfo: [ NSURLErrorFailingURLErrorKey: url, NSURLErrorFailingURLStringErrorKey: url.absoluteString, "HTTPStatusCode": response.statusCode, ] ) )
Topic: Streaming SubTopic:
HTTP Live Streaming Q&A
3h
Reply to AVAssetResourceLoaderDelegate and error handling
We were seeing some rare cases of sudden drift on live streams, where content would appear to be playing normally, and then we would suddenly see the audio and video be minutes apart from each other. This appeared to be related to HTTP 503 and 304 responses from the CDN on .m3u8 playlists. This issue didn’t happen on a brand new project, using an AVPlayer without a resource loader delegate, so we suspected that our own handling of these responses in our own AVAssetResourceLoaderDelegate could be the cause. We changed our code to the following, to handle the case of the 503s and other codes within the 400s-500s ranges. This did seem to solve the issue, but we weren't 100% certain if this was the right approach. Based on your answer, it sounds like we should just pass the HTTP code in directly instead of the "code: NSURLErrorBadServerResponse". loadingRequest.finishLoading( with: NSError( domain: NSURLErrorDomain, code: NSURLErrorBadServerResponse, userInfo: [ NSURLErrorFailingURLErrorKey: url, NSURLErrorFailingURLStringErrorKey: url.absoluteString, "HTTPStatusCode": response.statusCode, ] ) )
Topic: Streaming SubTopic:
HTTP Live Streaming Q&A
Replies
Boosts
Views
Activity
3h