Ravi Kiran
Ravi Kiran

Reputation: 671

I cant Stop my video which is playing in YTPlayerView ios

In my ios app I am using Googles YTPlayerView to load You tube videos, I can able to Play videos , But i cant able to stop The videos which is playing, on tap of Done button of the webviews Player It is exiting from full screen and automatically opening fullscreen, How do i stop the Videos ? i tried the following code to get notification on tap on Done but its not getting called

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playbackDidEnd:)
                                                 name:@"MPAVControllerItemPlaybackDidEndNotification"
                                               object:nil];

Is there any way to stop the videos or is there any way to get notification for Done Button Tap?

I also tried YTPlayerView's delegate method but it is not called on tap of done -(void)playerView:(YTPlayerView *)playerView didChangeToState:(YTPlayerState)state

Upvotes: 1

Views: 879

Answers (2)

keepsmiling
keepsmiling

Reputation: 370

In YTPlayerView-iframe-player.html, remove or comment below code.

window.setInterval(forcePlay, 5000);

Reference : https://stackoverflow.com/a/29306099/2696038

Upvotes: 2

Rajesh Loganathan
Rajesh Loganathan

Reputation: 11217

Pause your video by adding these lines in viewDidDisappear method in your class file .m

-(void)viewDidDisappear:(BOOL)animated
{
    [self.Player pauseVideo];
}

Upvotes: 1

Related Questions