0
내 앱에서 사용자는 카메라 롤에서 동영상을 선택하고 앱 내에서 재생할 수 있습니다. 처음 비디오를 선택하면 모든 것이 잘됩니다. 그러나 비디오가 끝나고 다른 비디오를 선택하면 오디오를들을 수 있지만 비디오 컨트롤러는 화면에 표시되지 않습니다.여러 동영상을 재생할 때 MPMoviePlayer가 표시되지 않습니다.
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
self.videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
[self dismissViewControllerAnimated:NO completion:nil];
[self Play];
}
-(void)Play
{
self.player = [[MPMoviePlayerController alloc]initWithContentURL:self.videoURL];
self.player.shouldAutoplay = YES;
self.player.allowsAirPlay = YES;
self.player.view.frame = self.view.frame;
[self.view addSubview: self.player.view];
[self.player setFullscreen:YES animated:YES];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.player];
[self.player play];
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
NSLog(@"MovieDone");
[self.player.view removeFromSuperview];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.player];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
[self.navigationController popToRootViewControllerAnimated:YES];
}
- (void) exitedFullscreen:(NSNotification*) aNotification {
NSLog(@"MovieDone");
[self.player.view removeFromSuperview];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerDidExitFullscreenNotification
object:self.player];
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
[self.navigationController popToRootViewControllerAnimated:YES];
}