1
我有一個音樂應用程序。在SoundCloud這樣的鎖定屏幕中顯示歌曲信息和音樂控件的最佳方式是什麼?請參閱(http://cl.ly/image/1a1H041A1Z34)在鎖定屏幕上顯示音樂播放控件的最佳方式iOS7
非常感謝!
我有一個音樂應用程序。在SoundCloud這樣的鎖定屏幕中顯示歌曲信息和音樂控件的最佳方式是什麼?請參閱(http://cl.ly/image/1a1H041A1Z34)在鎖定屏幕上顯示音樂播放控件的最佳方式iOS7
非常感謝!
很有用的指南 - Lock screen 「Now Playing」 with MPNowPlayingInfoCenter;
這隻適用於iOS 5+,並做了這樣的事情。
- (void)setupNowPlayingInfoCenter:(MPMediaItem *)currentSong
{
NSString *ver = [[UIDevice currentDevice] systemVersion];
CGFloat version = 4.0;
if ([ver length] >= 3)
{
version = [[ver substringToIndex:3] floatValue];
}
if (version >= 5.0)
{
MPMediaItemArtwork *artwork = [currentSong valueForProperty:MPMediaItemPropertyArtwork];
MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter];
if (currentSong == nil)
{
infoCenter.nowPlayingInfo = nil;
return;
}
infoCenter.nowPlayingInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[currentSong valueForKey:MPMediaItemPropertyTitle], MPMediaItemPropertyTitle,
[currentSong valueForKey:MPMediaItemPropertyArtist], MPMediaItemPropertyArtist,
[currentSong valueForKey:MPMediaItemPropertyAlbumTitle], MPMediaItemPropertyAlbumTitle,
[currentSong valueForKey:MPMediaItemPropertyAlbumTrackCount], MPMediaItemPropertyAlbumTrackCount,
[currentSong valueForKey:MPMediaItemPropertyAlbumTrackNumber], MPMediaItemPropertyAlbumTrackNumber,
artwork, MPMediaItemPropertyArtwork,
[currentSong valueForKey:MPMediaItemPropertyComposer], MPMediaItemPropertyComposer,
[currentSong valueForKey:MPMediaItemPropertyDiscCount], MPMediaItemPropertyDiscCount,
[currentSong valueForKey:MPMediaItemPropertyDiscNumber], MPMediaItemPropertyDiscNumber,
[currentSong valueForKey:MPMediaItemPropertyGenre], MPMediaItemPropertyGenre,
[currentSong valueForKey:MPMediaItemPropertyPersistentID], MPMediaItemPropertyPersistentID,
[currentSong valueForKey:MPMediaItemPropertyPlaybackDuration], MPMediaItemPropertyPlaybackDuration,
[NSNumber numberWithInt:self.mediaCollection.nowPlayingIndex + 1], MPNowPlayingInfoPropertyPlaybackQueueIndex,
[NSNumber numberWithInt:[self.mediaCollection count]], MPNowPlayingInfoPropertyPlaybackQueueCount, nil];
}
}
下一次,嘗試使用搜索:
非常感謝您! – jpblack
問題已被標記爲重複,除了解決問題的代碼我添加了相當有用的教程以解釋以下代碼... – ignotusverum