在使用AVPlayer播放背景音乐的过程中,如何在ios 7上的遥控器上设置标题音乐?
答案 0 :(得分:2)
你想要的课程是MPNowPlayingInfoCenter。
创建一个值字典并将它们传递给它,就像这样......
NSMutableDictionary *info=[NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"Song title",@"Artist name",nil] forKeys:[NSArray arrayWithObjects: MPMediaItemPropertyTitle,MPMediaItemPropertyArtist,nil]];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:info];
确保导入以下内容:
#import <MediaPlayer/MPNowPlayingInfoCenter.h>
#import <MediaPlayer/MPMediaItem.h>
#import <MediaPlayer/MPMediaQuery.h>
字典中的键如下:
MPMediaItemPropertyAlbumTitle
MPMediaItemPropertyAlbumTrackCount
MPMediaItemPropertyAlbumTrackNumber
MPMediaItemPropertyArtist
MPMediaItemPropertyArtwork
MPMediaItemPropertyComposer
MPMediaItemPropertyDiscCount
MPMediaItemPropertyDiscNumber
MPMediaItemPropertyGenre
MPMediaItemPropertyPersistentID
MPMediaItemPropertyPlaybackDuration
MPMediaItemPropertyTitle
MPNowPlayingInfoPropertyElapsedPlaybackTime
MPNowPlayingInfoPropertyPlaybackRate;
MPNowPlayingInfoPropertyPlaybackQueueIndex;
MPNowPlayingInfoPropertyPlaybackQueueCount;
MPNowPlayingInfoPropertyChapterNumber;
MPNowPlayingInfoPropertyChapterCount;
源: