iosobjective-ciphonecfnetworkcore-media

iOS Not playing some Videos - CoreMediaErrorDomain Code=-12939


I am using CTVideoView to playback videos inside a UITableView in iOS. As of late this was working fine, but for some reason, it seems as though the something has gone astray.

About 10% of the videos will play in the table, but many will simply just fail to play. The error occurs when iOS is trying to download the video as can be seen by the error messages below. For some reason, the error message is different in iOS 10 & 11 but the code is the same.

Based on iOS 10's message one would believe that the network is not available, but if I point my safari/chrome browser on the same iOS device it plays the video just fine.

As for the iOS 11 message, I have no idea where to even start as it the first time I've seen this message.

Any help at all would be much appreciated in resolving this.

iOS 10 Error Message

FAILED TO PREPARE VIDEO WITH ERROR: Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo={NSLocalizedDescription=unknown error, NSErrorFailingURLStringKey=URLOBSCUREDFORPRIVACY, NSErrorFailingURLKey=URLOBSCUREDFORPRIVACY, NSURL=URLOBSCUREDFORPRIVACY, NSUnderlyingError=0x17044bd00 {Error Domain=CoreMediaErrorDomain Code=-12939 "CFNetwork error unavailable" UserInfo={NSDescription=CFNetwork error unavailable, NSURL=URLOBSCUREDFORPRIVACY}}}

iOS 11 Error Message

FAILED TO PREPARE VIDEO WITH ERROR: Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo={NSUnderlyingError=0x1c08483d0 {Error Domain=CoreMediaErrorDomain Code=-12939 "content range mismatch - should be start 0 length 1247166 is start 0 length 1048575" UserInfo={NSDescription=content range mismatch - should be start 0 length 1247166 is start 0 length 1048575, NSURL=URLOBSCUREDFORPRIVACY}}, NSErrorFailingURLStringKey=URLOBSCUREDFORPRIVACY, NSErrorFailingURLKey=URLOBSCUREDFORPRIVACY, NSURL=URLOBSCUREDFORPRIVACY, NSLocalizedDescription=unknown error}

Update (Possible Clue)

So after some testing I've narrowed it down to videos longer than or equal to 10 seconds. In all other circumstances the video will play.


Solution

  • I have resolved the issue. The issue was with ParseServer and the fact that it could not stream videos to iOS as it does not come out of the box with byte-range headers configured.

    The solution was to implement the GridStoreAdapter into the server and from there migrate file storage to S3 or GCS (depending on your preference). This will need to be done alongside the respective adapter for your service.

    Once that was done, the app started behaving correctly again.