Reputation: 23725
My app keeps crashing whenever I try to play a video, despite the fact that my AVPlayer instance is being retained.
NSURL *url = [[NSBundle mainBundle] URLForResource:@"dd4dcafeea5111e1ad6712313b030e5d" withExtension:@"mp4"];
self.videoPlayer = [AVPlayer playerWithURL:url];
[self addSubview:self.videoPlayer];
[((AVPlayer *)self.videoPlayer) play];
It's being assigned to this property:
@property (strong) id videoPlayer;
What's going on here? Am I not retaining something I should be?
Upvotes: 0
Views: 1088
Reputation: 40211
AVPlayer
is not a subclass of UIView
. You can't add a model object to your view hierarchy.
Upvotes: 2