ios 视频播放

NSString*path=[[NSBundle mainBundle] pathForResource:@"a" ofType:@"mp4"];
    NSURL *url=[NSURL fileURLWithPath:path];
    movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [movie prepareToPlay];
    movie.movieSourceType=MPMovieSourceTypeFile;
    movie.controlStyle = MPMovieControlStyleFullscreen;
    [movie.view setFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
    movie.initialPlaybackTime = -1;
    movie.controlStyle=MPMovieControlStyleNone;
    [self.view addSubview:movie.view];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:nil];
    [movie play];



经反复测试,支持mov、MP4格式的文件,不管文件大小。但是不支持mpg格式的文件

你可能感兴趣的:(ios 视频播放)