控制iphone音乐播放器的相关函数

GlovePod是一款开源项目,允许用户在不脱下手套的情况下控制手机音乐播放。通过双击锁屏上的主页按钮显示媒体播放器,用户可以使用音量加减键切换歌曲,长按电源键来播放或暂停音乐。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://github.com/rono23/GlovePod

国外牛人的开源工程,其说明如下

You can control music without taking off your gloves!

To use, double-tap home in the lock screen to show the media player.
Then, you can switch to the next/previous track by pressing the increase/decrease volume button.
Additionally, you can play/stop a tune by holding the power button



其中有一些很有用的函数

static BOOL isLocked()
{
return [[objc_getClass("SBAwayController") sharedAwayController] isLocked];
}

static BOOL isDimmed()
{
return [[objc_getClass("SBAwayController") sharedAwayController] isDimmed];
}

static BOOL isVisible()
{
return [[objc_getClass("SBAwayController") sharedAwayController] isShowingMediaControls];
}

static BOOL isPlaying()
{
return [[objc_getClass("SBMediaController") sharedInstance] isPlaying];
}

static BOOL isCalling()
{
return [[objc_getClass("SBTelephonyManager") sharedTelephonyManager] inCall];
}

static BOOL isPowerButtonEnabled()
{
return ((isLocked() && !isCalling()) &&
((LSiPodVisiblePowerButtonEnabled && isVisible()) ||
(LSScreenOnPowerButtonEnabled && !isDimmed() && !isVisible()) ||
(LSScreenOffPowerButtonEnabled && isDimmed())));
}

static BOOL useDefaultVolumeAction(BOOL enabled)
{
return (!isLocked() || (isLocked() && !isPlaying()) || !enabled);
}


/*==============================================================================
==============================================================================*/


static void $SpringBoard$invokeGPPowerButton(SpringBoard *self, SEL sel)
{
invocationGPPowerButtonTimerDidFire = YES;
[[objc_getClass("SBMediaController") sharedInstance] togglePlayPause];
}

static void startInvocationGPPowerButtonTimer()
{
invocationGPPowerButtonTimerDidFire = NO;

SpringBoard *springBoard = (SpringBoard *)[objc_getClass("SpringBoard") sharedApplication];
invocationGPPowerButtonTimer = [[NSTimer scheduledTimerWithTimeInterval:0.7f
target:springBoard selector:@selector(invokeGPPowerButton) userInfo:nil repeats:NO] retain];
}

static void cancelInvocationGPPowerButtonTimer()
{
[invocationGPPowerButtonTimer invalidate];
[invocationGPPowerButtonTimer release];
invocationGPPowerButtonTimer = nil;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值