1

I am trying to show live streaming in bottom left corner of my screen,Currently live video is playing smoothly with all controls(Play, pause ,volume,full screen).But close/done button is not there.so I am not able to close live streaming window at any time I want to close it.I am using AVPlayer to achive same .Below is my code.

I have tried MPPlayer also but had same problem with that.

I had taken one close button and tried playerlayer.removefromsuperlayer but this also not worked for me.

I just want one close button which will close live streaming from my app

Please suggest any another player if they support close functionality

NSURL *videourl = [NSURL URLWithString:@"my url"];

AVPlayer *player = [AVPlayer playerWithURL:videourl];

AVPlayerViewController *playerViewController = [AVPlayerViewController new];

playerViewController.player = player;

playerViewController.view.frame =  CGRectMake(0, 400, 300, 200);

AVPlayerLayer* playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = CGRectMake(0, 400, 300, 200);

playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
//externalPlaybackVideoGravity
playerLayer.contentsGravity = AVLayerVideoGravityResizeAspect;

playerViewController.showsPlaybackControls = YES;
[self addChildViewController:playerViewController];
[self.view.layer addSublayer:playerLayer];
[self.view addSubview:playerViewController.view];

playerViewController.player.muted = TRUE;

[playerViewController.player play];
Roman Podymov
  • 4,168
  • 4
  • 30
  • 57
  • What do you mean by "to close live streaming window at any time I want to close it"? Do you want to dismiss the controller that contains `playerViewController`? If so, why do you want to do it with `AVPlayerViewController` controls? – Roman Podymov Apr 07 '20 at 12:32
  • Yes,I want to close playerViewController (that player layer which is upper layer) and (I am beginner to iOS ) – Pratiksha Mhatre Apr 07 '20 at 13:47
  • Does this answer your question? [Draw button on top of AVPlayer](https://stackoverflow.com/questions/36368673/draw-button-on-top-of-avplayer) – Roman Podymov Apr 11 '20 at 10:03

0 Answers0