OStack程序员社区-中国程序员成长平台

标题: ios - 如何播放视频.mp4 ios7? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 14:58
标题: ios - 如何播放视频.mp4 ios7?

我无法播放视频,因为我收到此通知错误:

    - (void)playbackFinishedNSNotification*)notification {
        NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
        switch ([reason intValue]) {

            case MPMovieFinishReasonPlaybackError:{
                **NSLog(@"playbackFinished. Reason: Playback Error");**
                [UIView animateWithDuration:1.0f
                                      delay:0
                                    options:UIViewAnimationOptionCurveEaseIn
                                 animations:^{

                                     [m_player.view setAlpha:0];

                                 }
                                 completion:^(BOOL finished){

                                     [m_player.view removeFromSuperview];
                                     m_player = nil;
                                 }];
            }
                break;

            default:
                break;
        }


 }

感谢任何帮助!



Best Answer-推荐答案


您需要找出为什么会出现播放错误,然后才能弄清楚需要做什么才能解决问题。

查看 this closely related question 的答案,您将看到以下代码片段:

    NSError *mediaPlayerError = [[notification userInfo] objectForKey"error"];
    if (mediaPlayerError) 
    {
        NSLog(@"playback failed with error description: %@", [mediaPlayerError localizedDescription]);
    }
    else
    {
        NSLog(@"playback failed without any given reason");
    }

将这些行添加到您的 MPMovieFinishReasonPlaybackError 案例中,您可能会弄清楚您的应用程序到底出了什么问题。祝你好运!

关于ios - 如何播放视频.mp4 ios7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19041746/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4