有一種方法可將圖像添加到背景音頻鎖定屏幕,同時設置音軌和藝術家名稱。在WWDC 2011的視頻中也提到了這一點,但沒有具體的結果。我在文檔中無處不在,找不到它。我知道這是一個iOS5的唯一的東西,Spotify的最新版本有這個功能。有沒有人知道他們可以指向正確的方向?背景音頻 - 鎖定屏幕上的圖像
謝謝你, 馬修
有一種方法可將圖像添加到背景音頻鎖定屏幕,同時設置音軌和藝術家名稱。在WWDC 2011的視頻中也提到了這一點,但沒有具體的結果。我在文檔中無處不在,找不到它。我知道這是一個iOS5的唯一的東西,Spotify的最新版本有這個功能。有沒有人知道他們可以指向正確的方向?背景音頻 - 鎖定屏幕上的圖像
謝謝你, 馬修
這裏有一個答案,我發現你:
(1)你必須處理的遠程控制事件。除非你這樣做,否則你不能成爲現在的 。 (見AudioMixer (MixerHost) sample) code)。
(2)將正在播放的信息:
MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter];
infoCenter.nowPlayingInfo =
[NSDictionary dictionaryWithObjectsAndKeys:@"my title", MPMediaItemPropertyTitle,
@"my artist", MPMediaItemPropertyArtist,
nil];
這是獨立於任何一個API使用的是播放音頻或視頻 的。
按照邁克爾上述回答,只是追加
@{MPMediaItemPropertyArtwork: [[MPMediaItemArtwork alloc] initWithImage:[UIImage ...]]}
到nowPlayingInfo字典
可用密鑰的全部選項...
// MPMediaItemPropertyAlbumTitle
// MPMediaItemPropertyAlbumTrackCount
// MPMediaItemPropertyAlbumTrackNumber
// MPMediaItemPropertyArtist
// MPMediaItemPropertyArtwork
// MPMediaItemPropertyComposer
// MPMediaItemPropertyDiscCount
// MPMediaItemPropertyDiscNumber
// MPMediaItemPropertyGenre
// MPMediaItemPropertyPersistentID
// MPMediaItemPropertyPlaybackDuration
// MPMediaItemPropertyTitle
爲了控制工作...
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated {
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent {
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlPlay:
[player play];
break;
case UIEventSubtypeRemoteControlPause:
[player pause];
break;
case UIEventSubtypeRemoteControlTogglePlayPause:
if (player.playbackState == MPMoviePlaybackStatePlaying) {
[player pause];
}
else {
[player play];
}
break;
default:
break;
}
}
}
它僅適用於一個真實的iOS設備,而不是在模擬器上
酷!!!!!!!!!!!! – Zhou 2012-11-14 18:28:38
非常感謝。 – jarryd 2013-04-04 09:44:52
你如何設置鎖定屏幕圖像? – openfrog 2013-07-23 11:48:16