AVPlayerViewController contentOverlayView iOS 8
AVPlayerViewController contentOverlayView iOS 8
- Subject: AVPlayerViewController contentOverlayView iOS 8
- From: "Mazzaroth M." <email@hidden>
- Date: Fri, 19 Jun 2015 19:42:53 -0400
Hi all, am I using the contentOverlayView correctly below? I just want to
get something showing up so that I know I'm going in the right direction so
I just want to render a red square but I do not see anything appear in the
AVPlayerViewController.view
viewDidLoad (of view controller that is presenting the
AVPlayerViewController subclass)
self.playerViewController = [[SCRPlayerViewController alloc] init];
// SCRPlayerViewController is a subclass of AVPlayerViewController because
I wish to override default playback orientation to landscape
UIView *contentOverlay = [[UIView alloc]
initWithFrame:CGRectMake(100.0, 100.0, 100.0, 100.0)];
[contentOverlay setBackgroundColor:[UIColor redColor]];
[self.playerViewController.contentOverlayView
addSubview:contentOverlay];
// 1 ***
Later on I do this:
AVPlayerItem *item = [[AVPlayerItem alloc] initWithAsset:asset];
if (item != nil)
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector
(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:item];
}
AVQueuePlayer *p = [AVQueuePlayer queuePlayerWithItems:[NSArray
arrayWithObject:item]];
[self.playerViewController setPlayer:p];
p.allowsExternalPlayback = YES;
p.usesExternalPlaybackWhileExternalScreenIsActive = YES;
[p seekToTime:kCMTimeZero];
[p play];
// 2 ***
NSLog(@"do playback self.playerViewController.contentOverlayView: %@",
self.playerViewController.contentOverlayView);
[self presentViewController:self.playerViewController animated:YES
completion:^{
NSLog(@"complete");
}];
finally in playerItemDidReachEnd:
- (void)playerItemDidReachEnd:(NSNotification *)notification
{
NSLog(@"reached the end of %@", notification);
//3 ***
NSLog(@"playerItemDidReachEnd
self.playerViewController.contentOverlayView: %@",
self.playerViewController.contentOverlayView);
}
~~~~~~~~
At // 1 *** and // 2 *** self.playerViewController.contentOverlayView is
nil!
Only at // 3 *** is self.playerViewController.contentOverlayView not nil!
2015-06-19 19:29:59.252 foo[1861:956007] playerItemDidReachEnd
self.playerViewController.contentOverlayView: <UIView: 0x165474e0; frame =
(0 0; 480 320); layer = <CALayer: 0x165493b0>>
But this is too late clearly because playback has concluded. Regardless, If
I restart playback at this point without tearing-down the view controllers,
I STILL do not see a red square despite
self.playerViewController.contentOverlayView being not nil.
Documentation on contentOverlayView is rather sparse. Any suggestions?
maz
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden