0

在使用AVPlayer在后台播放音乐期间,如何在ios 7上的遥控器上设置标题音乐?

4

1 回答 1

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;

资源:

https://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPNowPlayingInfoCenter_Class/Reference/Reference.html

于 2013-12-05T16:42:34.190 回答