私はさまざまな説明を求めてGoogleを閲覧してきましたが、このコードがいつ起動して画面が真っ暗になるのかまだわかりませんでした. 誰でも間違いを見つけることができますか?
アップデート
- (IBAction)playVideo:(id)sender {
NSURL *videoUrl = [[DataStore singletonInstance] getVideoUrl:self withUuid:self.eventDetailVC.event.uuid];
if ([videoUrl checkResourceIsReachableAndReturnError:nil] == NO) {
NSLog(@"Video doesn't not exist.");
return;
}
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoUrl];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[previewView addSubview:player.view];
player.view.frame = previewView.bounds;
player.controlStyle = MPMovieControlStyleDefault;
[player play];
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
NSLog(@"moviePlayBackDidFinish: called");
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
// Checking for errors
NSDictionary *notiUserInfo = [notification userInfo];
if (notiUserInfo != nil) {
NSError *errorInfo = [notiUserInfo objectForKey:@"error"];
if ([[errorInfo domain] isEqualToString:@"MediaPlayerErrorDomain"]) {
UIAlertView *notice = [[UIAlertView alloc] initWithTitle:@"Error"
message:[errorInfo localizedDescription]
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[notice show];
return;
}
}
// Remove from view
[player.view removeFromSuperview];
[player stop];
}
参考までに、moviePlayBackDidFinish はまったく呼び出されません。どうしてか分かりません。