9
當您播放音樂時,音樂標題顯示在鎖定屏幕的時間下方。如何在iPhone鎖定屏幕上設置當前正在播放的音頻的標題?
我也看過TuneIn收音機是如何通過顯示當前正在播放的電臺的名稱來實現的。
你是怎麼做的?
當您播放音樂時,音樂標題顯示在鎖定屏幕的時間下方。如何在iPhone鎖定屏幕上設置當前正在播放的音頻的標題?
我也看過TuneIn收音機是如何通過顯示當前正在播放的電臺的名稱來實現的。
你是怎麼做的?
這裏是一個示例代碼,將在iOS 5的工作並不會崩潰的舊版iOS。
Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
if (playingInfoCenter) {
MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
NSDictionary *songInfo = [NSDictionary dictionaryWithObjectsAndKeys:
@"Some artist", MPMediaItemPropertyArtist,
@"Some title", MPMediaItemPropertyTitle,
@"Some Album", MPMediaItemPropertyAlbumTitle,
nil];
center.nowPlayingInfo = songInfo;
}
謝謝!難道僅僅在iOS5中只有一節課是無法完成的。 – samwize
必須有一些方法可以在沒有iOS5的情況下做到這一點... –
不存在,因爲此API僅適用於iOS 5.在iOS之前,沒有API可以實現這一點。 – rckoenes