0
當我嘗試通過iOS 4.3上的MPMoviePlayerViewController播放電影時,現在出現了一個奇怪的問題。 它看起來只是一個白色的屏幕,沒有任何反應。我的代碼在iOS 4.2上運行良好。所以我創建了一個新的OpenGLES項目,並使用我的電影代碼,但它也無法工作。那麼任何人都可以提供一些建議嗎? 在此先感謝。MPMoviePlayerViewController無法在iPhone或iPad上的iOS 4.3上工作
我的代碼如下:
//-------------------------------------TestViewController.h---------------------------------------
#import <MediaPlayer/MediaPlayer.h>
@interface TestViewController : UIViewController
{
bool _isMovieEnded;
MPMoviePlayerViewController* _theMovie;
}
- (void)playMovie:(NSString*)filename;
- (void)movieFinishedCallback:(NSNotification*)aNotification;
- (bool)isMovieEnd;
//-------------------------------------TestViewController.m---------------------------------------
- (void)playMovie:(NSString*)filename
{
NSURL* theURL = [NSURL fileURLWithPath:filename];
_theMovie = [[MPMoviePlayerViewController alloc] init];// initWithContentURL:theURL];
[_theMovie.moviePlayer setContentURL:theURL];
_theMovie.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[_theMovie.moviePlayer setControlStyle:MPMovieControlStyleNone];
[_theMovie.moviePlayer setFullscreen:YES];
// register notification
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_theMovie];
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[_theMovie.moviePlayer play];
[self.view addSubview:_theMovie.view];
}
- (void)movieFinishedCallback:(NSNotification*)aNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:_theMovie];
// release movie
[_theMovie.view removeFromSuperview];
[_theMovie release];
_isMovieEnded = true;
[self startAnimation];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}
- (bool)isMovieEnd
{
return _isMovieEnded;
}
//-------------------------------------TestAppDelegate.m---------------------------------------
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[self.window addSubview:self.viewController.view];
NSString* movieFile = [[NSBundle mainBundle] pathForResource:@"logo" ofType:@"mp4"];
[viewController playMovie:movieFile];
[viewController stopAnimation];
return YES;
}