Post

Replies

Boosts

Views

Activity

Reply to AVPlayer
Claude, it seems I am having trouble adding the button to my avplayer. The button never shows when I use avMovie.view or self.view when I try to add the subView. Any suggestions?-(void)playMovie: (NSString *) fileName{ NSLog(@"in playMovie second"); NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: fileName ofType:@"mp4"]]; AVPlayer *player = [AVPlayer playerWithURL:url]; AVPlayerViewController *avMovie = [[AVPlayerViewController alloc]init]; //AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; avMovie.view.frame = self.view.bounds; avMovie.player = player; //playerLayer.frame = self.view.bounds; //[playerLayer setVideoGravity:AVLayerVideoGravityResizeAspect]; //[self.view.layer addSublayer:playerLayer]; [player play]; //make button UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(30,30,100,60); [button setTitle:@"Done" forState:UIControlStateNormal]; [button addTarget:self action:@selector(myDoneButtonMethod:) forControlEvents:UIControlEventTouchUpInside]; [avMovie.view addSubview:button]; //show view controller [self addChildViewController:avMovie]; [self.view addSubview:avMovie.view]; //avMovie.view.frame = self.view.frame; //[player replaceCurrentItemWithPlayerItem:nil]; //[player pause]; //[avMovie.view removeFromSuperview]; }
Jan ’20
Reply to AVPlayer
I used[avMovie.view removeFromSuperview];to remove the view. However, the player does not have a "Back/done" button. Do I have to manually code one in or is there a title or subtitle feature that allows me to enter this functionality?
Jan ’20