在锁定 iPhone iOS 时,我想要 YTPlayerView 中的下一个和上一个按钮,实际上当我在模拟器中使用下一个和上一个按钮时效果很好,但是当我在 iPhone 锁定时按下下一个按钮然后它崩溃时,我在我的应用程序中使用 YTPlayerView。
我在应用程序委托中的代码是
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];
}
我的应用程序在下一个崩溃..