I'm initialising an MPMoviePlayerViewController
to a source .mp4 on a server which supports Range requests and all that, and in fact the code I am using works fine on an iPhone 4, iPhone 3GS and iPad running iOS 4.
I have an iPhone 3G running iOS 4. The movie player class on this device begins to stream, and then immediately finishes playback. It doesn't error, though, it simply finishes playback as evidenced by printing the MPMoviePlaybackDidFinishNotification
; it comes back with MPMoviePlayerPlaybackDidFinishReasonUserInfoKey = 0
, which I take to mean MPMovieFinishReasonPlaybackEnded
considering that's the first value of the enum. I've even tried setting a playback hint, MPMovieSourceType = MPMovieSourceTypeStreaming
.
The issue is that if I navigate to the very same URL in Safari on the iPhone 3G, it streams and plays the movie without error. I'm totally stumped, and Google has so far turned up nothing specific to the 3G. Possible solutions include creating a custom AVFoundation
implementation (not at all ideal) or using MPMoviePlayerController
on 3G devices. If someone has guidance on switching based on the model of iPhone, not the version of iOS running, that would be great.
Using CFNotificationObserver callback registration, I have received the following notifications of interest:
Name: AVFileValidatorNotification_NotPlayable <-- likely the source of the issue
Info: Error = "Error
Domain=NSOSStatusErrorDomain
Code=-12621
\"This movie could not be played.\" "
Name: FailedToBecomeReadyForInspection
Info: Properties = ( InitialSamples );
Result = "-12621";
Name: AVController_ItemFailedToPlay
Info: "AVController_Error" = (the above Error object);
"AVController_Item" = "<MPAVItem: 0x1b65d0>";
Name: MPAvControllerPlaybackStateChangedNotification
// Got several of these, the playback state changed as follows: 0 -> 2 -> 7 -> 0