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];
}
}
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>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With