- (void)playMethod
{
NSURL *url = [[NSURL alloc] initWithString:@"https://www.rmp-streaming.com/media///bbb-360p.mp4"];
player = [AVPlayer playerWithURL:url];
controller = [[AVPlayerViewController alloc] init];
[self addChildViewController:controller];
[self.view addSubview:controller.view];
//to rotate to the landscape on click of play button
[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft) forKey:@"orientation"];
[UINavigationController attemptRotationToDeviceOrientation];
//to open the view
controller.view.frame = CGRectMake(0,0,667,375);
controller.player = player;
controller.showsPlaybackControls = YES;
player.closedCaptionDisplayEnabled = NO;
CALayer* overlayLayer = [CALayer layer];
UIImage* overlayImage = nil;
overlayImage = [UIImage imageNamed:@"apple.png"];
//Create the parent layer
CALayer *parentLayer = [CALayer layer];
parentLayer.frame = CGRectMake(0, 0, 20, 20);
CALayer *videoLayer = [CALayer layer];
videoLayer.frame = CGRectMake(0, 0, 20, 20);
[parentLayer addSublayer: videoLayer];
[parentLayer addSublayer: overlayLayer];
//Composes the composited video frame with a core animation layer
AVVideoCompositionCoreAnimationTool *animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer: videoLayer inLayer: parentLayer];
// to add the back button on player
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 addTarget:self
action:@selector(backMethod)
forControlEvents:UIControlEventTouchUpInside];
[button1 setTitle:@"Back" forState:UIControlStateNormal];
[button1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button1.frame = CGRectMake(50.0, CGRectGetMinY(controller.view.frame)+10, 160.0, 40.0);
button1.tag = 1001;
[self.view addSubview:button1];
[controller.view bringSubviewToFront:button1];
[player pause];
[player play];
}
Я пытаюсь добавить оверлей на видео, но с помощью приведенного выше кода ничего не произошло.Подскажите, пожалуйста, как мне поступить с кодом.Я не вижу никакого эффекта на видео, оно все то же, что и раньше.