ios 设备上有互动电影。当电影开始时(点击),视频开头的人会问你插入耳机,如果插入,那么视频应该自动跳转到故事(直接进入视频故事)。我应该怎么办?以及如何编写代码?
首先,您必须注册 AudioRoute Changes:-
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange,
audioRouteChangeListenerCallback,
self);
在这里您可以描述更改路线的原因:-
CFDictionaryRef routeChangeDictionary = inPropertyValue;
CFNumberRef routeChangeReasonRef =
CFDictionaryGetValue (routeChangeDictionary,
CFSTR (kAudioSession_AudioRouteChangeKey_Reason));
SInt32 routeChangeReason;
CFNumberGetValue (routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason);
if (routeChangeReason == kAudioSessionRouteChangeReason_OldDeviceUnavailable)
{
// your statements for headset unplugged
}
if (routeChangeReason == kAudioSessionRouteChangeReason_NewDeviceAvailable)
{
// your statements for headset plugged
}
关于ios - 检测耳机是否已插入 iOS 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10685313/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |