Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用带音频播放器的锁屏按钮?_Ios_Objective C_Avaudioplayer - Fatal编程技术网

Ios 如何使用带音频播放器的锁屏按钮?

Ios 如何使用带音频播放器的锁屏按钮?,ios,objective-c,avaudioplayer,Ios,Objective C,Avaudioplayer,我使用此代码显示有关曲目的信息,并使用播放/暂停按钮 -(void)info { UIImage *image = [UIImage imageNamed:@"image.png"]; NSInteger highScore = [[[NSUserDefaults standardUserDefaults] objectForKey:@"int"] intValue]; MPMediaItemArtwork *albumArtwork = [[MPMediaItemArtwork alloc

我使用此代码显示有关曲目的信息,并使用播放/暂停按钮

-(void)info
{
UIImage *image = [UIImage imageNamed:@"image.png"];

NSInteger highScore = [[[NSUserDefaults standardUserDefaults] objectForKey:@"int"] intValue];

MPMediaItemArtwork *albumArtwork = [[MPMediaItemArtwork alloc] initWithImage:image];

MPNowPlayingInfoCenter* mpic = [MPNowPlayingInfoCenter defaultCenter];
mpic.nowPlayingInfo = @{MPMediaItemPropertyArtist: @"1",
                        MPMediaItemPropertyTitle:[NSString stringWithFormat:@"1 %ld",(long)highScore],
                        MPMediaItemPropertyArtwork:albumArtwork,
                        MPMediaItemPropertyAlbumTitle: @"1",
                        MPNowPlayingInfoPropertyElapsedPlaybackTime:[NSNumber numberWithFloat: [self.audioPlayer getCurrentAudioTime]],
                        MPMediaItemPropertyPlaybackDuration : [NSNumber numberWithFloat:[self.audioPlayer getAudioDuration]]};
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent {

if (receivedEvent.type == UIEventTypeRemoteControl) {

    switch (receivedEvent.subtype) {

        case UIEventSubtypeRemoteControlPreviousTrack:
            NSLog(@"prev");
            break;

        case UIEventSubtypeRemoteControlNextTrack:
            NSLog(@"next");
            break;

        case UIEventSubtypeRemoteControlPlay:
            [_audioPlayer playAudio];
            break;

        case UIEventSubtypeRemoteControlPause:
            [_audioPlayer pauseAudio];
            break;

        default:
            break;
    }
}
}
我想在苹果音乐应用程序中使用倒带按钮(如下图)

如果我点击按钮audioPlayer,移动到下一个曲目。若我长按按钮,轨迹是倒带。怎么做?

将这两行添加到 “-(无效)viewDidLoad”


我有个问题。setDelegate已弃用。
 [[AVAudioSession sharedInstance] setDelegate: self];
 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];