0

我正在将应用程序从 iOS6 移植到 iOS7。有一个奇怪的问题是在完成按钮呼叫后屏幕变黑。我试过这个这个这个

没有合适的答案,我觉得理论上使用以前的方法应该没有任何问题。

请向我提供一些关于为什么会出现此问题的线索。

谢谢

4

3 回答 3

1

这可以帮助在您的 .h 文件中导入 MediaPlayer

#import <MediaPlayer/MediaPlayer.h>

做一个属性

@property (strong, nonatomic) MPMoviePlayerController *moviePlayer;

之后,您可以通过此播放视频

-(void)playMovie:(id)sender
{
  NSURL *url = [NSURL URLWithString:
  @"http://www.xyz.com/ios_book/movie/movie.mov"];

_moviePlayer =  [[MPMoviePlayerController alloc]
             initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
               selector:@selector(moviePlayBackDidFinish:)
               name:MPMoviePlayerPlaybackDidFinishNotification
               object:_moviePlayer];

_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];
}

之后删除视频视图添加这个

   - (void) moviePlayBackDidFinish:(NSNotification*)notification {
   MPMoviePlayerController *player = [notification object];
   [[NSNotificationCenter defaultCenter]
    removeObserver:self
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:player];

  if ([player
    respondsToSelector:@selector(setFullscreen:animated:)])
 {
    [player.view removeFromSuperview];
 }
 }
于 2013-11-30T16:57:02.697 回答
-1

在主窗口上添加您的电影播放器​​控制器视图,例如:

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString:@"map.mp4"]]; 

[player prepareToPlay]; 

[player.view setFrame: self.view.bounds];

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[appDelegate.window addSubview: player.view];

[player play];

希望它对你有用!

于 2013-10-21T11:54:44.707 回答
-2

Try this way..

ViewController.m

MPMoviePlayerViewController *mp=[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:[[arr_videos objectAtIndex:indexPath.row]valueForKey:@"Video_path"]]];

MPMoviePlayerController *pc=[mp moviePlayer];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[self presentViewController:mp animated:YES completion:nil];
[pc prepareToPlay];
[pc play];
于 2013-10-21T13:32:37.587 回答