如何在iOS 7锁屏上设置当前播放持续时间和已用时间? [英] How to set current playback duration and elapsed time on iOS 7 lockscreen?

查看:446
本文介绍了如何在iOS 7锁屏上设置当前播放持续时间和已用时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从iOS 5开始,每个音乐播放器都可以在[MPNowPlayingInfoCenter defaultCenter]上设置当前播放的音乐信息,如标题,艺术家,专辑标题和插图.nowPlayingInfo将显示在锁定屏幕上。

Starting from iOS 5, every music player can set current playing music information such as title, artist, album title, and artwork on [MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo to show on lock screen.

在iOS 7上,播放位置滑块,持续时间和经过时间信息被添加到锁定屏幕和控制中心。但是,我找不到任何文件来设置这些类型的信息并启用滑块来改变播放位置。

On iOS 7, playback position slider, duration, and elapsed time information are added to both lock screen and control center. However, I cannot find any documents to set these kinds of information and enable the slider to change playback position.

有没有办法解决这个问题?

Is there any way to solve this problem?

推荐答案

你需要将播放速率设置为1.0f,即使文档说它默认为1.0。

You need to setup playback rate to 1.0f even if documentation says it's 1.0 by default.

NSDictionary *mediaInfo = @{
    MPMediaItemPropertyTitle: audio.title,
    MPMediaItemPropertyArtist: audio.artist,
    MPMediaItemPropertyPlaybackDuration: audio.duration,
    MPNowPlayingInfoPropertyPlaybackRate: @(1.0)
};

[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo];

这篇关于如何在iOS 7锁屏上设置当前播放持续时间和已用时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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