播放视频

播放视频方法一

MPMoviePlayerController *moviePlayer;
moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[coursewareRow objectForKey:@"网址"]]];
//    moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4”]]];//本地文件
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer prepareToPlay];
[moviePlayer play];

 
播放视频方法二该方法有时候会莫名其妙加载其他视图控制器里边的图片

MPMoviePlayerViewController *moviePlayerViewController;
    moviePlayerViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[coursewareRow objectForKey:@"网址"]]];
    [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

 

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