Vuko
Vuko

Reputation: 109

iOS - Use AVPlayerViewController in AVKit obj-c

I am trying to update this deprecated method: 'presentMoviePlayerViewControllerAnimated' however I am not able to import AVKit and use AVPlayerViewContoller. It seems like my Xcode is not seeing this framework somehow.

Here is my code:

MatchDetailsVC.m

   -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath (NSIndexPath *)indexPath {
YoutubeVideoModel* video = [_videos objectAtIndex:indexPath.row];

XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:video.videoID];
   =>[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController];

Cannot access the AVKit files: using CM + click

MatchDetalisVC.m UPDATE

[self presentViewController:videoPlayerViewController animated:YES completion:nil];

Changed the last line with this. No errors. It seems I don't have to #import AVKit in my ViewController as well. Is it correct though?

Upvotes: 1

Views: 4595

Answers (1)

Trần Thị Diệu My
Trần Thị Diệu My

Reputation: 1413

added this line, just working

#import <AVKit/AVKit.h>

Upvotes: 4

Related Questions