Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer forward class declaration

So I have this AVPlayerViewController nested inside a container view in my storyboard. I access this player vide controller using prepareForSegue. But when I attempt to set any properties on the player property of it, Xcode gives me an error Receiver 'AVPlayer' for class message is a forward declaration. I have AVKit correctly imported in the .h. What am I doing wrong?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {  
    if ([segue.identifier isEqualToString:@"videoPlayerEmbed"]) {
        self.videoPlayerController = (AVPlayerViewController *)segue.destinationViewController;
        self.videoPlayerController.delegate = self;
        self.videoPlayerController.player = [[AVPlayer alloc] init];
    } else {
        [super prepareForSegue:segue sender:sender];
    }
}

like image 886
DemosJarco Avatar asked Jul 13 '15 07:07

DemosJarco


1 Answers

I figured it out. I thought #import <AVKit/AVKit.h> was enough for AVPlayerViewController but if you want to manage the AVPlayer you also need #import <AVFoundation/AVFoundation.h>.

like image 196
DemosJarco Avatar answered Nov 04 '22 15:11

DemosJarco