Error Handling with the Native SDK for iOS

In this topic, you will learn how the Brightcove Native SDK for iOS handles playback errors.

Overview

Error codes have the term ErrorCode in the name. For example:

	kBCOVPlaybackSessionErrorCodeLoadFailed

Events have the word Event in the name. For example:

	kBCOVPlaybackSessionLifecycleEventFail

Playback errors

Playback errors are handled through events. Generally speaking you would receive playback errors using the lifecycle event delegate callback on the BCOVPlaybackController:

	- (void)playbackController:(id<BCOVPlaybackController>)controller
          playbackSession:(id<BCOVPlaybackSession>)session
 didReceiveLifecycleEvent:(BCOVPlaybackSessionLifecycleEvent *)lifecycleEvent;

To get further information, do the following:

  1. If you get an error event such as kBCOVPlaybackSessionLifecycleEventFail, kBCOVPlaybackSessionLifecycleEventError or kBCOVPlaybackSessionLifecycleEventFailedToPlayToEndTime, check the event's properties dictionary for the kBCOVPlaybackSessionEventKeyError (@"error") key. kBCOVPlaybackSessionLifecycleEventResumeFail does not carry an error.

    This will provide an NSError object with information about the problem.

  2. Each NSError will have an error domain, like the following:

    • NSCocoaErrorDomain
    • kBCOVPlaybackSessionErrorDomain
     

    Each error domain will have an associated error code and error description, like the following:

    • kBCOVPlaybackSessionErrorCodeLoadFailed
    • kBCOVPlaybackSessionErrorCodeNoPlayableSource
  3. Some errors will also have an underlying error that can be retrieved from the error object's userInfo dictionary with the NSUnderlyingErrorKey key. This will typically be a system NSError that can provide more information.

  4. To find all the error domains in the SDK, search the headers for the following:

    	ErrorDomain

    Here is a list of headers that have ErrorDomain references:

    • BrightcovePlayerSDK-Swift.h (FairPlay, offline video manager, and Playback Service APIs)
    • BCOVPlaybackSessionConstants.h (playback session events and errors)
  5. To find all the error codes, search each ErrorDomain for the following:

    	ErrorCode

    For example, in BCOVPlaybackSessionConstants.h, you'll see kBCOVPlaybackSessionErrorDomain with the following error codes:

    • kBCOVPlaybackSessionErrorCodeLoadFailed
    • kBCOVPlaybackSessionErrorCodeFailedToPlayToEnd
    • kBCOVPlaybackSessionErrorCodeNoPlayableSource
  6. Other domains may return errors differently. For example, the BCOVPlaybackService object will return errors in its completion blocks if there are network errors when requesting videos from the online catalog. It uses the error domain BCOVPlaybackService.ErrorDomain.

Playback errors table

Here is a list of possible playback errors from the Native SDK for iOS. Be aware that errors can also be passed through from the underlying framework.

iOS playback errors
Header Error Description
BrightcovePlayerSDK-Swift.h BCOVFPSConstants.ErrorDomain Error domain for FairPlay related errors
BCOVFPSErrorCodeStreamingContentKeyRequest Error occured requesting content key
BCOVFPSErrorCodeApplicationCertificateRequest Error occured requesting application certificate
BrightcovePlayerSDK-Swift.h BCOVFPSBrightcoveAuthProxy.ErrorDomain Error domain for FairPlay Auth Proxy related errors.
BCOVFPSAuthProxyErrorCodeApplicationCertificateRequestFailed Request for Application Certificate failed
BCOVFPSAuthProxyErrorCodeContentKeyRequestFailed Request for Key failed
BCOVFPSAuthProxyErrorCodeContentKeyGenerationFailed Key request generation failed
BrightcovePlayerSDK-Swift.h BCOVPlaybackServiceErrorCodeNoError No error.
BCOVPlaybackServiceErrorCodeConnectionError Error Code that indicates there was an error connecting to the Playback API. Check the error.userInfo key NSUnderlyingErrorKey for the actual connection error.
BCOVPlaybackServiceErrorCodeJSONDeserializationError Error Code that indicates there was an error parsing the response as JSON. If the request returned any data, that raw NSData will be included in the userInfo by key BCOVPlaybackService.ErrorKeyRawResponseData. Check the error.userInfo key NSUnderlyingErrorKey for the actual JSON deserialization error.
BCOVPlaybackServiceErrorCodeAPIError Error Code that indicates there was an error returned by the API. Check the error.userInfo key BCOVPlaybackService.ErrorKeyAPIErrors for an NSArray of errors returned by the API and key BCOVPlaybackService.ErrorKeyAPIHTTPStatusCode to find the status code returned.
BCOVPlaybackService.ErrorDomain Error domain for BCOVPlaybackService.
BCOVPlaybackService.ErrorKeyRawResponseData Key for NSError.userInfo for errors with domain BCOVPlaybackService.ErrorDomain and errorCode BCOVPlaybackServiceErrorCodeJSONDeserializationError. This is the raw response data. This may not exist in error.userInfo.
BCOVPlaybackService.ErrorKeyAPIErrors Key for NSError.userInfo for errors with domain BCOVPlaybackService.ErrorDomain and errorCode BCOVPlaybackServiceErrorCodeAPIError. This is an NSArray of errors returned by the Playback API.
BCOVPlaybackService.ErrorKeyAPIHTTPStatusCode Key for NSError.userInfo for errors with domain BCOVPlaybackService.ErrorDomain and errorCode BCOVPlaybackServiceErrorCodeAPIError. This is the HTTP status code returned by the API request.
BCOVPlaybackSessionConstants.h kBCOVPlaybackSessionLifecycleEventFail The video failed to load. The event properties contain the underlying error keyed by kBCOVPlaybackSessionEventKeyError.
kBCOVPlaybackSessionLifecycleEventFailedToPlayToEndTime

The video failed during playback and was unable to recover, possibly due to a network error. The event properties contain the underlying error keyed by kBCOVPlaybackSessionEventKeyError when AVFoundation reports one.

It may be possible to recover from this error once the network has recovered, by using the [BCOVPlaybackController resumeVideoAtTime:withAutoPlay:] method.

kBCOVPlaybackSessionLifecycleEventResumeFail The player could not reload the video after a call to resumeVideoAtTime:withAutoPlay:. This event does not carry an error.
kBCOVPlaybackSessionLifecycleEventError A generic error occurred, for example cellular playback is not allowed, a FairPlay error, or a Generic Stream Concurrency error. The event properties may contain the underlying error keyed by kBCOVPlaybackSessionEventKeyError.
kBCOVPlaybackSessionLifecycleEventThumbnailAssetFailedToLoad The thumbnail seeking asset failed to load. The event properties may contain the underlying error keyed by kBCOVPlaybackSessionEventKeyError.
kBCOVPlaybackSessionEventKeyError The key for the error in the Event properties.
kBCOVPlaybackSessionErrorDomain Error domain for the SDK.
kBCOVPlaybackSessionErrorCodeLoadFailed The video failed to load.
kBCOVPlaybackSessionErrorCodeFailedToPlayToEnd The video failed during playback and was unable to recover, possibly due to a network error.
kBCOVPlaybackSessionErrorCodeNoPlayableSource No playable Source was available for this Video.
kBCOVPlaybackSessionErrorCodeWifiUnavailable No WiFi network is available and allowsCellularPlayback is disabled.