iOS版:显示当前播放的曲目信息中的LockScreen? [英] iOS: Displaying currently played track info in LockScreen?

查看:152
本文介绍了iOS版:显示当前播放的曲目信息中的LockScreen?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着iOS 5的,我们有机会获得 MPNowPlayingInfoCenter 在锁屏和多任务栏上的多媒体控件来显示信息。我有发挥的本地音频文件的应用程序。我想显示像艺术家的姓名信息,专辑和在锁定屏幕上的作品与 MPNowPlayingInfoCenter ,但要做到这一点(据我所知)的唯一方法是使用 MPMusicPlayerController 并获得 nowPlayingItem ...问题是, MPMusicPlayerController 用于只播放iPod中的音乐,而不是本地存储的文件。有没有办法解决iOS 5中?

As of iOS 5 we have access to MPNowPlayingInfoCenter to display info in the lockscreen and in the multimedia controls on the multitasking bar. I have an app that plays local audio files. I want to display info like the artist's name, the album and the artwork on the lockscreen with MPNowPlayingInfoCenter, but the only way to do this (As far as I know) is to use MPMusicPlayerController and get nowPlayingItem... The problem is that MPMusicPlayerController is used to play iPod Music only, and not locally stored files. Is there a way around this in iOS 5?

推荐答案

您可以创建自己的NSDictionary,并提供了对MPNowPlayingInfoCenter。

You can create your own NSDictionary and supply that to the MPNowPlayingInfoCenter.

NSArray *keys = [NSArray arrayWithObjects:MPMediaItemPropertyAlbumTitle, MPMediaItemPropertyArtist, ..., nil];
NSArray *values = [NSArray arrayWithObjects:@"Album", @"Artist", ..., nil];
NSDictionary *mediaInfo = [NSDictionary dictionaryWithObjects:values forKeys:keys];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo];

这篇关于iOS版:显示当前播放的曲目信息中的LockScreen?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆