2011-12-05 22 views

回答

27

閱讀文檔:MPNowPlayingInfoCenter

這裏是一個示例代碼,將在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; 
} 
+0

謝謝!難道僅僅在iOS5中只有一節課是無法完成的。 – samwize

+0

必須有一些方法可以在沒有iOS5的情況下做到這一點... –

+0

不存在,因爲此API僅適用於iOS 5.在iOS之前,沒有API可以實現這一點。 – rckoenes

相關問題