iOS7 issue on Playing mov file in MPMoviePlayerViewController

孤者浪人 提交于 2019-12-13 04:01:18

问题


I was able to play .mov file using following coding in ios 6.1.3 and below but in iOS7 it closed automatically.

MPMoviePlayerViewController *mp1 = [[ MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
if (mp1)
{
    self.moviePlayer= mp1;
    [mp1 release];
    self.moviePlayer.view.userInteractionEnabled=YES;
    self.moviePlayer.moviePlayer.repeatMode = MPMovieRepeatModeOne;

    self.moviePlayer.view.frame = CGRectMake(0, 0, 320, 460);
    [self.moviePlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];

    self.moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleDefault;

    //Register for the playback finished notification.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(myMovieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:self.moviePlayer.moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerDidExitFullscreenNotification object:self.moviePlayer.moviePlayer];

    //setup device rotation notification observer
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(didRotate:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];

    [self.masterVC presentMoviePlayerViewControllerAnimated:moviePlayer];
    [self.moviePlayer.moviePlayer prepareToPlay];
    [self.moviePlayer.moviePlayer play];
    [self.moviePlayer.moviePlayer setFullscreen:TRUE];

}

Using above coding I can able to play .mp4 file in iOS7 and all. Does apple restricted mov files?


回答1:


I may be having the same issue as you. If you look at your logs, do you get the following error:

_itemFailedToPlayToEnd: { 
    kind = 1; 
    new = 2; 
    old = 0;
}

The only other idea I have is to use a new class such as AVPlayer or even a third party class to play my media. I don't see any settings that are incorrect in your code nor my code. It is iOS 7 related though.



来源:https://stackoverflow.com/questions/19088955/ios7-issue-on-playing-mov-file-in-mpmovieplayerviewcontroller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!