【发布时间】:2019-05-03 16:37:31
【问题描述】:
亲爱的同事,您好,我需要您的帮助。当我添加 MPChangePlaybackPositionCommand 时,我的所有控件(锁屏上的播放/暂停/重播/下一曲目)都已自动禁用。锁屏上播放的滑块完美运行,但我无法按下任何控制按钮 - 我不知道。
我也试过这个:
[[MPRemoteCommandCenter sharedCommandCenter].playCommand setEnabled:YES];
[[MPRemoteCommandCenter sharedCommandCenter].pauseCommand setEnabled:YES];
[[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand setEnabled:YES];
[[MPRemoteCommandCenter sharedCommandCenter].nextTrackCommand setEnabled:YES];
我的代码很简单:
MPChangePlaybackPositionCommand *changePlaybackPositionCommand = [[MPRemoteCommandCenter sharedCommandCenter] changePlaybackPositionCommand];
[changePlaybackPositionCommand addTarget:self action:@selector(onChangePlaybackPositionCommand:)];
- (MPRemoteCommandHandlerStatus) onChangePlaybackPositionCommand:
(MPChangePlaybackPositionCommandEvent *) event
{
[[[PlayerPlistController utilise]miniplayer] seekToTime:CMTimeMakeWithSeconds(event.positionTime, 1)];
NSLog(@"changePlaybackPosition to %f", event.positionTime);
return MPRemoteCommandHandlerStatusSuccess;
}
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
[songInfo setObject:NAME_TITLE forKey:MPMediaItemPropertyTitle];
[songInfo setObject:NAME_TITLE_SLOGON forKey:MPMediaItemPropertyAlbumTitle];
UIImage *image = [UIImage imageNamed:PLACEHOLDER_EMPTY];
MPMediaItemArtwork *imageArt = [[MPMediaItemArtwork alloc] initWithBoundsSize:image.size requestHandler:^UIImage* _Nonnull(CGSize aSize) { return image; }];
[songInfo setObject:imageArt forKey:MPMediaItemPropertyArtwork];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
【问题讨论】:
-
@matt 不一样,因为我的滑块工作得很好。我也使用 - - (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent 但没有一个积极的结果...=\
-
而且我的信息中心工作正常,因为我在锁屏上有名字歌曲
-
您说您的滑块运行良好,但显然情况并非如此,因为它禁用了界面的其余部分。我不是专家,但在我看来,关于更新指挥中心有关播放速率和播放位置的信息的建议在这里可能非常密切。
-
@matt 我的滑块可以完美运行,因为我可以更改播放器的播放速率。调用 MPRemoteCommandCenter 时,所有控件都已禁用...
标签: ios xcode avplayer mpremotecommandcenter