I want next and previous button in my YTPlayerView while locked iPhone iOS, actually when I use next and previous button in simulator its works well, but when I press next button while iPhone is locked then its crashes, I am using YTPlayerView in my app.
My code in app delegate is
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
//comment below hide next and previous
MPRemoteCommandCenter *rcc = [MPRemoteCommandCenter sharedCommandCenter];
MPRemoteCommand *nextTrackCommand = [rcc nextTrackCommand];
[nextTrackCommand setEnabled:YES];
[nextTrackCommand addTarget:self action:@selector(nextTrackCommandAction)];
// Doesn’t show unless nextTrack is enabled
MPRemoteCommand *previousTrackCommand = [rcc previousTrackCommand];
[previousTrackCommand setEnabled:YES];
[previousTrackCommand addTarget:self action:@selector(previousTrackCommandAction)];
-(void)nextButtonMethod{
NSDictionary *playerVars = @{
@"controls" : @1,
@"playsinline" : @1,
@"autohide" : @1,
@"modestbranding" : @1,
@"showinfo" : @1
};
[[YTPlayerInstance instance] loadWithVideoId:@"LlrY456zAMU" playerVars:playerVars];
}
My app is crashing on next..