开发者

MPMoviePlayerViewController not palying in ipod and iPhone

-(void)playVideo:(NSURL *)url{

    if (videoPlayer) {
        [videoPlayer release];
        videoPlayer = nil;
    }
    videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    url = nil;
    videoPlayer.moviePlayer.controlStyle=MPMovieControlStyleFullscreen;
    videoPlayer.view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
    videoPlayer.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    videoPlayer.view.backgroundColor = [UIColor blackColor]; 


    [[UIApplication sharedApplication]
     setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];


    [videoPlayer.moviePlayer prepareToPlay];
    videoPlayer.moviePlayer.shouldAutoplay = YES;
    videoPlayer.hidesBottomBarWhenPushed = YES;
    self.navigationController.navigationBarHidden=NO;
    videoPlayer.navigationItem.hidesBackButton = YES;
    [self.navigationController pushViewCo开发者_如何学Gontroller:videoPlayer animated:YES];

    [self addObservers];
}

Can anyone say what is wrong with this code? The url is streaming http link. Video player is appearing but after a while it disappears. It is working in 3G network but not in wifi


As you are saying that it was working on 3G but not on WiFi Network, your issue is most likely not related to the code but to the movie-file/s you are testing.

Make sure the m3u8-snippet is complete and valid also for low bandwidth. Test the m3u8 with Apples Mediastream Validator as described by this Best Practice Guide and this Article.


After this line:

videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];

add this:

[videoPlayer retain];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜