티스토리 뷰
#import <AudioToolbox/AudioToolbox.h>
콜백함수로 등록
// Registers the audio route change listener callback function
AudioSessionAddPropertyListener (
kAudioSessionProperty_AudioRouteChange,
audioRouteChangeListenerCallback,
self
);
콜백함수
void audioRouteChangeListenerCallback (
void *inUserData,
AudioSessionPropertyID inPropertyID,
UInt32 inPropertyValueSize,
const void *inPropertyValue
) {
CFDictionaryRef routeChangeDictionary = inPropertyValue;
CFNumberRef routeChangeReasonRef =
CFDictionaryGetValue (routeChangeDictionary,
CFSTR (kAudioSession_AudioRouteChangeKey_Reason));
SInt32 routeChangeReason;
CFNumberGetValue (routeChangeReasonRef, kCFNumberSInt32Type, &routeChangeReason);
if (routeChangeReason == kAudioSessionRouteChangeReason_OldDeviceUnavailable)
{
// Headset is unplugged..
NSLog(@"빠졌다!!");
}
if (routeChangeReason == kAudioSessionRouteChangeReason_NewDeviceAvailable)
{
// Headset is plugged in..
NSLog(@"꽂혔다!!");
}
}
'나름 프로그래밍? > Objective-C' 카테고리의 다른 글
UITextField 에 숫자만 입력받기 (0) | 2012.06.15 |
---|---|
NULL 체크 널값 걸러내기 (0) | 2012.05.11 |
파일 존재 여부 검사 (0) | 2012.05.09 |
UIWebView 다 불러온 페이지 소스 가져오기 (0) | 2011.09.29 |
NSString 한글 2바이트로 계산.. (0) | 2011.07.14 |