Video not play iOS 11.Overlay does not respond to touch.Video play button not show
Anbu312 opened this issue · 7 comments
you can call addChildViewController and addSubview methods in viewDidAppear. I fixed it like this.
- (void)viewDidAppear:(BOOL)animated
{
..........
[self addChildViewController:_overlayVC];
[self.view addSubview:_overlayVC.view];
[_overlayVC didMoveToParentViewController:self];
}
I am facing delay playing videos. anybody facing that issue. Below my code I load my video player to TableView give me any suggestion guys lot of helpful for me.
cell.playerVC.videoURL = @"Video Url";
cell.playerVC.overlayVC.view.tag = indexPath.row;
[cell.playerVC.view setFrame:cell.feedImage.bounds];
cell.playerVC.videoGravity = AVLayerVideoGravityResizeAspectFill;
[((UIView *)cell.feedImage) addSubview:cell.playerVC.view];
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayback
error: nil];
Video button now show Thanks for support but Video playing delay.
Video Button show sample code
AVPlayerVC.m file
Change below code
[self.view addSubview:_overlayVC.view]; replace to [self.contentOverlayView addSubview:_overlayVC.view];
It's working fine.
Do you remove an old player from the cell before addSubview:?
Hi @ios-apps
Thanks for response.
Actually My tableview load images and videos. cellForRowAtIndexPath check image or video. Video means add [((UIView )cell.feedImage) addSubview:cell.playerVC.view]; Image means [cell.playerVC.view removeFromSuperview];.
If the cell has already a player, you will add another one, and so on. Each cell will have a few players and your app will be slow, finally it will crash.
Set a tag to the player, for example 100 and 101 for the image. Find the assert by the tag and remove it before adding the new assert.
UIImageView *imageView = (UIImageView *)[cell viewWithTag:101];
[imageView removeFromSuperview];