Ios 启动屏幕视频未播放

Ios 启动屏幕视频未播放,ios,objective-c,video,splash-screen,Ios,Objective C,Video,Splash Screen,我用视频启动屏幕,但它没有播放,它显示黑色屏幕,这是我的代码 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"hello" ofType:@"mp4"]; NSURL* movieURL = [NSURL fileURLWithPath:moviePa

我用视频启动屏幕,但它没有播放,它显示黑色屏幕,这是我的代码

  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"hello" ofType:@"mp4"];
  NSURL* movieURL = [NSURL fileURLWithPath:moviePath];

  playerCtrl =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
  playerCtrl.scalingMode = MPMovieScalingModeFill;
  playerCtrl.controlStyle = MPMovieControlStyleNone;
  playerCtrl.view.autoresizingMask =UIViewAutoresizingFlexibleHeight;


 [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish)
                                             name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
 [self.window addSubview:playerCtrl.view];
 [playerCtrl play];

您可以尝试将播放器视图框设置为窗口边界吗?

您可以详细说明您的播放器视图的框为CGRectZero,因此您只能看到窗口。playerCtrl.frame=self.window.bounds应该可以解决这个问题,因为MPMovieScalingModeFill不会保留视频比例,而只是拉伸它来填充视图。您可以使用MPMovieScalingModeAspectFit或MPMovieScalingModeAspectFill,具体取决于您试图实现的目标