| 代码如下 | 复制代码 |
appDelegate里面加入如下代码获取后台播放权限 - (void)setAudioBackstagePlay{AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil]; [audioSession setActive:YES error:nil]; } //重写父类方法,接受外部事件的处理 - (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent { NSLog(@"remote"); if(receivedEvent.type == UIEventTypeRemoteControl) { switch(receivedEvent.subtype) {// 得到事件类型 caseUIEventSubtypeRemoteControlTogglePlayPause:// 暂停 ios6 [_player musicPause];// 调用你所在项目的暂停按钮的响应方法 下面的也是如此 break; caseUIEventSubtypeRemoteControlPreviousTrack:// 上一首 [self lastMusic]; break; caseUIEventSubtypeRemoteControlNextTrack:// 下一首 [self nextMusic]; break; caseUIEventSubtypeRemoteControlPlay://播放 [_player musicPlay]; break; caseUIEventSubtypeRemoteControlPause:// 暂停 ios7 [_player musicPause]; break; default: break; } } } - (void)configNowPlayingCenter {NSLog(@"锁屏设置"); // BASE_INFO_FUN(@"配置NowPlayingCenter"); YBVideoListModel * list = _model.audioList[_currentIndexPath.row]; //以下代码是加载锁屏显示网络图片以及其他设置[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:list.thumbUrl] options:SDWebImageRetryFailed progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if(image == nil) { image = [UIImage imageNamed:@"default_music"]; } NSMutableDictionary * info = [NSMutableDictionary dictionary]; //音乐的标题 [info setObject:list.title forKey:MPMediaItemPropertyTitle]; //音乐的艺术家 NSString *author= list.singer; [info setObject:author forKey:MPMediaItemPropertyArtist]; //音乐的播放时间 [info setObject:@(_player.player.currentTime.value) forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime]; //音乐的播放速度 [info setObject:@(1) forKey:MPNowPlayingInfoPropertyPlaybackRate]; //音乐的总时间 [info setObject:@(list.duration) forKey:MPMediaItemPropertyPlaybackDuration]; //音乐的封面 MPMediaItemArtwork * artwork = [[MPMediaItemArtwork alloc] initWithImage:image]; [info setObject:artwork forKey:MPMediaItemPropertyArtwork]; //完成设置 [[MPNowPlayingInfoCenter defaultCenter]setNowPlayingInfo:info]; }]; } | |
韩剧再婚皇后阿里云盘全集高清1080P资源链接-韩剧再婚皇后免费阿里云盘资源下载4K高清无删减版链接
poipiku网站如何打开-poipiku官网网页版访问入口
明日方舟:终末地-云游戏畅玩入口-明日方舟:终末地-网页版在线直连地址
poki在线小游戏网页版-poki免费游戏大全入口
poki游戏入口-点开即玩-poki游戏-在线免费畅玩
原神akt大佬资源viciNeko入口链接-原神akt大佬资源网页vicineko入口链接分享