简体   繁体   English

自iOS 4.3起MPMoviePlayerController无法流式传输.3gp视频

[英]MPMoviePlayerController failing to stream .3gp video since iOS 4.3

I have an existing iPhone/iPad universal app that streamed video with the MPMoviePlayerController over wi-fi (mp4) and 3G Network (3gp). 我有一个现有的iPhone / iPad通用应用程序,该应用程序通过wi-fi(mp4)和3G网络(3gp)通过MPMoviePlayerController流式传输视频。 When iOS 4.3 was released our 4.3 devices can no longer play a 3gp video over 3G network. 当iOS 4.3发布时,我们的4.3设备无法再通过3G网络播放3gp视频。 I tested a local 3gp file and that fails too, but works on a 3G phone running 4.2.x. 我测试了本地3gp文件,该文件也失败了,但是可以在运行4.2.x的3G手机上使用。

After debugging the view controller I see the MPMoviePlayerLoadStateDidChangeNotification notification is not being triggered when trying to play the 3gp file locally or streaming it via URL. 调试视图控制器后,我看到在本地播放3gp文件或通过URL流式传输时未触发MPMoviePlayerLoadStateDidChangeNotification通知。

[APPDEL showStatusView:  @"Please wait..."];

    NSString * videoUrl = [[request.URL description] stringByReplacingOccurrencesOfString: @"idvideo:" withString: @"http:"];
    DLog(@"Loading video %@", videoUrl);
    _moviePlayer = [[IDMoviePlayerController alloc] initWithContentURL: [NSURL URLWithString: videoUrl]];
    _moviePlayer.view.backgroundColor = [UIColor clearColor];
    _moviePlayer.allowsAirPlay = YES;

    _moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

    if ([_moviePlayer respondsToSelector:@selector(loadState)]) {
        // May help to reduce latency
        [_moviePlayer prepareToPlay];

        // Register that the load state changed (movie is ready)
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                                                         selector:@selector(moviePlayerLoadStateChanged:) 
                                                                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                                                                             object:_moviePlayer];

        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector(moviePlayerPreloadDidFinish:) 
                                                     name:MPMoviePlayerContentPreloadDidFinishNotification
                                                   object:_moviePlayer];


        //[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(moviePlayerTimerUp:) userInfo:nil repeats:NO];
    }  
    else {
        // Register to receive a notification when the movie is in memory and ready to play.
        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                                                         selector:@selector(moviePreloadDidFinish:) 
                                                                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                                                                             object:nil];
    }       

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

    if ([_moviePlayer respondsToSelector: @selector(view)]) {
        [self.view addSubview: _moviePlayer.view];

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            _moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
        }
        else {
            _moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
        }

        _moviePlayer.view.frame = _webView.frame;
    }

    [_moviePlayer play];

The first condition for the loadState is always hit. 始终会达到loadState的第一个条件。 For the 3gp file the code will never reach the moviePlayerLoadStateChanged selector method which hides an indicator/status view and creates other fullscreen/orientation notifications. 对于3gp文件,代码将永远无法到达moviePlayerLoadStateChanged选择器方法,该方法将隐藏指示器/状态视图并创建其他全屏/方向通知。 The indicator/status view will just remain up & spinning. 指标/状态视图将一直保持向上并旋转。 Within debugger I can see the onMovieDone selector method gets triggered far sooner than the video would of really of finished. 在调试器中,我可以看到onMovieDone选择器方法的触发时间比视频真正完成的时间要早​​得多。

Confused. 困惑。

This my answer in regards with playing .3gp file with iPhone ..... I have successfully played .3gp file with iphone sdk with using MpMoviePlayerController and my answer link is: 这是我关于使用iPhone播放.3gp文件的答案..... 我已经使用MpMoviePlayerController 成功使用iphone sdk播放了.3gp文件,我的答案链接是:

Link: https://stackoverflow.com/a/13088808/1092219 链接: https//stackoverflow.com/a/13088808/1092219

hope you will got help from my answer.........!! 希望你能从我的回答中得到帮助......... !! :)))))) :))))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM