【问题标题】:Splash Screen Video is not playing启动画面视频未播放
【发布时间】:2014-11-19 10:36:23
【问题描述】:

我正在使用视频作为启动画面,但它没有播放,它显示黑屏,这是我的代码

  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];

【问题讨论】:

    标签: ios objective-c video splash-screen


    【解决方案1】:

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

    【讨论】:

    • 能否详细说明
    • 您的播放器视图有一个 CGRectZero 框架,所以您只能看到窗口。 playerCtrl.frame = self.window.bounds 应该可以解决问题
    • 那是因为 MPMovieScalingModeFill 不会保留视频比例,而只是将其拉伸以填充视图。您可以使用 MPMovieScalingModeAspectFit 或 MPMovieScalingModeAspectFill,具体取决于您要实现的目标
    猜你喜欢
    • 2016-05-30
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多