0

I'm trying to code a video player in Objective-C using XCode & a guide, but I'm getting an error for some reason, and I'm quite new to Objective C, the exact error code is - Property 'frame' not found on object of type AVPlayer.

Viewcontroller.h

@property (nonatomic) IBOutlet AVPlayer *avPlayer;
@property (nonatomic, strong) NSMutableString *frame;

Viewcontroller.m

 - (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"vid" ofType:@"mp4"];
    NSURL *fileURL = [NSURL fileURLWithPath:filepath];
    self.avPlayer = [AVPlayer playerWithURL:fileURL];

    AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
    self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    layer.frame = CGRectMake(0, 0, 1024, 768); //error point
    [self.view.layer addSublayer: layer];

    [self.avPlayer play];
}

I've been following this guide - http://jacopretorius.net/2013/02/playing-video-in-ios.html after trying multiple others.

My question is, why doesn't declaring the 'frame' work, I've also tried multiple ID's for the AVPlayer object & different ways to code the video player.

I've also tried -

Stackoverflow error Stackoverflow error 2

Community
  • 1
  • 1
Gerwin
  • 1,572
  • 5
  • 23
  • 51

1 Answers1

1

The error message states you are attempting to use AVPlayer.frame and not AVPlayerLayer.frame, so I think you've mis-typed the code with something like this:

AVPlayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
^^^^^^^^
trojanfoe
  • 120,358
  • 21
  • 212
  • 242