今日は丸一日かけて MPMoviePlayerViewController を iOS5 で動作させましたが、どうにかして動作させることができませんでした! 次のコードは、iOS 5.0 以外のすべての iOS で問題なく動作します。このトピックに関連するヘルプはあまり得られませんでした。iOS 5.0 で何が変更され、次の単純なコードがバーストしたのか、誰にもわかりません。iOS 5.0 では、loadstate を MPMovieLoadStateUnknown にチェックする無限ループに陥っていることに気付きました! Playableになることはありません!
#import "MyMoviePlayer.h"
@implementation MyMoviePlayer
@synthesize moviePlayerViewController;
- (void) checkAndPlay:(UIViewController *)view {
if ([[moviePlayerViewController moviePlayer] loadState] == MPMovieLoadStateUnknown) {
NSLog(@"Rechecking");
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(checkAndPlay:) userInfo:nil repeats:NO];
} else {
[moviePlayerViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[view presentModalViewController:moviePlayerViewController animated:YES];
}
}
- (void)play:(NSURL*)movieURL andWithView:(UIViewController *)view {
moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self checkAndPlay:view];
}