[AVPlayerViewController setPlayer:]: unrecognized selector sent to instance 0x101b91980 error.
I am trying to play a video using AVPlayerViewController.
@property (nonatomic) AVPlayer *avPlayer;
@property (nonatomic) AVPlayerViewController* avPlayerView;
NSString *path = [[NSBundle mainBundle] pathForResource:@"SampleVideo_1280x720_1mb" ofType:@"mp4"];
NSURL *url = [[NSURL alloc] initFileURLWithPath: path];
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset];
_avPlayer = [AVPlayer playerWithPlayerItem:anItem];
[AVPlayer addObserver:self forKeyPath:@"status" options:0 context:nil];
self.avPlayerView = [[AVPlayerViewController alloc] init];
self.avPlayerView.view.frame = self.view.bounds;
[self.avPlayerView setPlayer:_avPlayer];
[self.view addSubview:_avPlayerView.view];
but it is crashing. If i use same code in a new project, video play nicely.What is the problem?Please help.