NetworkConfig
@objcMembers
@objc(BMPNetworkConfig)
public class NetworkConfig : NSObject
The network config gives the ability to influence network requests. At the moment only changing DRM and HLS Playlist requests are supported. Processing responses or influencing the retry behaviour is not supported.
-
Type definition for the handler that needs to be called if a retry should happen.
Declaration
Swift
public typealias RetryHandler = (_ retryDelay: TimeInterval, _ request: HttpRequest) -> VoidParameters
retryDelayThe delay in seconds before the retry should happen.
requestThe request that should be done to retry the failed request. It can be the same as the failed request or a modified version of it.
-
Type definition for the handler that needs to be called if no retry should happen.
Declaration
Swift
public typealias AbortHandler = () -> Void -
Type definition for the handler that allows implementing a custom retry behaviour for failed HTTP requests.
Declaration
Swift
public typealias RetryHttpRequestHandler = ( _ type: HttpRequestType, _ retry: Int, _ response: HttpResponse, _ retryHandler: @escaping RetryHandler, _ abortHandler: @escaping AbortHandler ) -> VoidParameters
typeThe type of the failed request.
retryThe number of the current retry attempt.
responseThe response of the failed request. It contains a reference to the failed request.
retryHandlerHandler that needs to be called if a retry should happen.
abortHandlerHandler that needs to be called if no retry should happen.
-
Type definition for the handler that allows processing HTTP responses.
Declaration
Swift
public typealias PreprocessHttpResponseHandler = ( _ type: HttpRequestType, _ response: HttpResponse, _ completionHandler: @escaping (_ response: HttpResponse) -> Void ) -> VoidParameters
typeThe type of the request.
responseThe response of the request.
completionHandlerCompletion handler which must be called with the modified HTTP response.
-
Called before a HTTP request is made.
Only changing DRM and HLS Playlist requests are currently supported.
Declaration
Swift
public weak var preprocessHttpRequestDelegate: PreprocessHttpRequestDelegate? -
Called when an HTTP request has failed. Will override the default retry behaviour.
Called for HLS playlist, FairPlay certificate and FairPlay license requests.
If a custom
retryHttpRequesthandler is set, no internal retry handling is done at all. The custom handler needs to take care of all retries. Some things to consider when implementing an own handler are:- Make sure to have a maximum number of allowed retries to not retry unreasonable amount of times.
- There is an underlying
AVFoundationlimit of about 20 seconds for doing retries. If a failed request is not retried successfully within that time, there will be an error. Within that time frame, the amount of retries that can be done is unlimited.
Example:
networkConfig.retryHttpRequest = { requestType, retryCount, response, retryHandler, abortHandler in // Retry 3 times guard retryCount <= 3 else { // Abort retrying when threshold was reached abortHandler() return } // Customize delay for the next retry let retryDelay: TimeInterval = 1 // Retry the original request again retryHandler(retryDelay, response.request) }Declaration
Swift
public var retryHttpRequest: RetryHttpRequestHandler? -
Called after an HTTP response is received. Can be used to the access or change properties of the response before it gets into the player.
Called for HLS playlist, FairPlay certificate and FairPlay license requests.
Example:
networkConfig.preprocessHttpResponse = { type, response, completionHandler in switch type { case .manifestHlsVariant: // Modify variant playlist response let modifiedResponse = ... completionHandler(modifiedResponse) case .mediaSubtitles: // Modify variant playlist response let modifiedResponse = ... completionHandler(modifiedResponse) default: completionHandler(response) break } }Declaration
Swift
public var preprocessHttpResponse: PreprocessHttpResponseHandler?
NetworkConfig Class Reference