MPMovieController 全黑(虽然里面没有橄榄球 :D :D)

发布于 2024-12-10 11:05:50 字数 1642 浏览 0 评论 0原文

我的客户要求我将一段短视频作为启动画面来阅读(例如,这是专门为游戏而做的)。我用谷歌搜索了一下,我认为这些人使用 MPMoviePlayerController 并将 StyleControl 设置为 None (如果我错了,请纠正我......) 我尝试使用 iPhone 上的视频(通常格式正确,所以......),但仍然是黑屏。我的背景是红色的,我看到它出现在开头,然后它被我的视频隐藏,视频保持黑色并且永远不会开始。 然而,我设置了我的视频的框架(self.view 在当时被初始化),我添加了播放器来查看我的 self.view ...总之,我看不出有什么可能会乱七八糟。 这是代码(使用全屏控件尝试查看,但我也从未看到它们。 有什么想法吗? 谢谢大家;)

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    MPMoviePlayerController * mMoviePlayer;
    // Do any additional setup after loading the view, typically from a nib.

    NSURL* mMovieURL;
    NSBundle *bundle = [NSBundle mainBundle];
    if (bundle) 
    {
        NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"mov"];
        if (moviePath)
        {
            mMovieURL = [NSURL fileURLWithPath:moviePath];
        }
    }
    NSLog(@"%@", mMovieURL);

    [[UIApplication sharedApplication] setStatusBarHidden:YES];

    mMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mMovieURL];
    //    mMoviePlayer.scalingMode = MPMovieScalingModeAspectFill;
    mMoviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    [mMoviePlayer.view setFrame: self.view.bounds];  // player's frame must match parent's
    [self.view addSubview: mMoviePlayer.view];

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

)

My client asks me to read a short video as a splahscreen (as it is done especially for games for example). I googled for a bit and I think the guys use a MPMoviePlayerController with StyleControl to None (correct me if I'm wrong...)
I tried with a video from my iPhone (normally in the right format so ....), but remains black. My background is red, I see it appear at the beginning, then it is hidden by my video, which remains black and never starts.
However, I set out the frame of my video (self.view is initialized at the time), I add the player to view my self.view ... In short, I do not see what might messing around.
This is the code (with FullScreen controls to try to see, but I never see them either.
An idea by any chance?
Thx guys ;)

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    MPMoviePlayerController * mMoviePlayer;
    // Do any additional setup after loading the view, typically from a nib.

    NSURL* mMovieURL;
    NSBundle *bundle = [NSBundle mainBundle];
    if (bundle) 
    {
        NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"mov"];
        if (moviePath)
        {
            mMovieURL = [NSURL fileURLWithPath:moviePath];
        }
    }
    NSLog(@"%@", mMovieURL);

    [[UIApplication sharedApplication] setStatusBarHidden:YES];

    mMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mMovieURL];
    //    mMoviePlayer.scalingMode = MPMovieScalingModeAspectFill;
    mMoviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    [mMoviePlayer.view setFrame: self.view.bounds];  // player's frame must match parent's
    [self.view addSubview: mMoviePlayer.view];

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2024-12-17 11:05:50

你可以尝试:

[player setFullscreen:YES];

you may try:

[player setFullscreen:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文