簡體   English   中英

我可以隱藏iOS鎖屏音樂控件中的倒帶按鈕嗎?

[英]Can I hide the rewind button in the iOS Lock Screen Music controls?

我的應用程序不支持返回到以前的曲目,我想知道我是否可以告訴鎖屏音樂控件隱藏其倒帶/上一曲目按鈕。 我使用MPNowPlayingInfoCenter將該信息傳遞給鎖定屏幕。

很簡單的問題,可以嗎? 例如,僅顯示“播放/暫停”和“向前跳轉”?

從iOS 7.1開始,有一種方法可以自定義鎖定屏幕和命令中心(以及可能的許多其他附件)中可用的控件: MPRemoteCommandCenter

關於您的問題,您可以執行以下操作:

[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = NO;
[MPRemoteCommandCenter sharedCommandCenter].skipBackwardCommand.enabled = NO;
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = NO;

// You must also register for any other command in order to take control
// of the command center, or else disabling other commands does not work.
// For example:
[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(play)];

有關MPRemoteCommandCenter的更多常規信息,請參閱此Stack Overflow答案

過時的:

我認為簡短的回答是否定的。 文件說這個 -

“您無法直接控制顯示哪些信息或其格式。您可以根據要提供給系統的信息設置正在播放的信息中心字典的值。系統或連接的附件處理信息以一致的方式顯示給所有應用。“

我發現如果我沒有設置nowPlayingInfo和MPNowPlayingInfoCenter,那么我試圖擺脫默認鎖定屏幕播放器的更改沒有注冊。 確保你正在設置MPNowPlayingInfoCenter.defaultCenter()。nowPlayingInfo,如下所示:

 var songInfo: NSMutableDictionary = [
        MPMediaItemPropertyTitle: "song title",
        MPMediaItemPropertyArtist: "artiest ",
    ]
    MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = songInfo as [NSObject : AnyObject]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM