當運行在設備3.1.2,爲什麼它也通過if(NSClassFromString(@「MPMoviePlayerViewController」)!= nil) 並做iOS4的代碼,然後它會崩潰,如何解決這個問題?Media Player基於iOS4和部署iOS3的問題
if(NSClassFromString(@"MPMoviePlayerViewController") != nil) {
// iOS 4 code
NSLog(@"MPMoviePlayerViewController");
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:AppDelegate.PushLink]];
if (mp) {
// save the movie player object
self.theMovie4 = mp;
[mp release];
//Present
[self presentMoviePlayerViewControllerAnimated:self.theMovie4];
// Play the movie!
self.theMovie4.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self.theMovie4.moviePlayer play];
}
}
else {
//iOS 3 Code
AppDelegate = nil;
AppDelegate = [[UIApplication sharedApplication] delegate];
[AppDelegate ForceHideNavigationBar];
theMovie3 = nil;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerContentPreloadDidFinishNotification
object:theMovie3];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie3];
// Register to receive a notification when the movie scaling mode has changed.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieScalingModeDidChange:)
name:MPMoviePlayerScalingModeDidChangeNotification
object:theMovie3];
theMovie3 = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:AppDelegate.PushLink]];
[theMovie3 play];
}
謝謝stitz – RAGOpoR 2010-06-28 00:52:17
這是一個巨大的幫助。謝謝你! – 2010-08-13 04:23:35
非常感謝!它拯救了我的一天! – 2010-09-04 06:44:22