如何更改锁定屏幕/控制中心的轨道位置?

编程入门 行业动态 更新时间:2024-10-24 06:38:49
本文介绍了如何更改锁定屏幕/控制中心的轨道位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用ios 7音乐应用程序播放歌曲时,用户可以使用滑块更改锁定屏幕/控制中心中的歌曲位置。滑块处于活动状态:

When playing a song with the ios 7 music app the user can use slider to change song position in the lock screen/the control center. Slider is active:

但是在我的应用程序中播放音乐的用户无法做到这一点。滑块未激活:

But when playing music in my app user can't do it. Slider isn't active:

如何在我的应用程序中启用这些功能?

How can i enable these feature in my app?

推荐答案

您可以在iOS 9.1及更高版本的MPRemoteCommandCenter的帮助下更改曲目位置。

You can change track position with help of MPRemoteCommandCenter on iOS 9.1 and higher.

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_0) { MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter]; [commandCenter.changePlaybackPositionCommand setEnabled:true]; [commandCenter.changePlaybackPositionCommand addTarget:self action:@selector(changedThumbSliderOnLockScreen:)]; }

和方法

- (MPRemoteCommandHandlerStatus)changedThumbSliderOnLockScreen:(MPChangePlaybackPositionCommandEvent *)event { // change position [self setCurrentPlaybackTime:event.positionTime]; // update MPNowPlayingInfoPropertyElapsedPlaybackTime [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo]; return MPRemoteCommandHandlerStatusSuccess; }

更多推荐

如何更改锁定屏幕/控制中心的轨道位置?

本文发布于:2023-10-08 02:43:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471277.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制中心   轨道   如何更改   屏幕   位置

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!