티스토리 뷰



현재 개발중인 앱에서 음악 재생을 위하여 AVPlayer 를 사용한다.


여러가지로 컨트롤해줘야 할 부분이 많지만, 


특히 음악을 듣는중에 전화가 왔을때, 알람 울렸을때... 뭐 이런상황이 생기면 


재생중이던 음악을 정지 시켰다가 다시 대생시키던가, 아니면 그냥 정지 시키던가 하는 작업을 해줘야한다.


이런상황을 캐치하기 위해서 AVPlayer를 사용할때는 AVAudioSession 을 이용하여 컨트롤 하고 있었다....


근데!!


iOS6.0 SDK 부터 AVAudioSession쪽이 엄청 많이 바뀌어 버렸음... ㅠㅠ


일단 -[AVAudioSession setDelegate:] 요 메소드부터 DEPRECATED 되어 버렸음. 


이말은 즉, AVAudioSessionDelegate 함수인 -beginInterruption, -endInterruption 을 사용하지 못한다는 뜻인데....


그래도 우리 애플형들이 다른 방법을 만들어 놨으니까 없앴겠지 하는 마음으로 


문서를 뒤적뒤적이다 보니...


delegate

Specifies the delegate object for the audio session. (Deprecated in iOS 6.0. Use the notifications described in the Notifications section of this class instead.) <- 여기에 친절히 써있음.

@property(assign) id<AVAudioSessionDelegate> delegate
Discussion

The delegate object must implement the protocol described in AVAudioSessionDelegate Protocol Reference.

Availability
  • Available in iOS 3.0 and later.
  • Deprecated in iOS 6.0.
Declared In
AVAudioSession.h 



AVAudioSessionInterruptionNotification

Posted when an audio interruption occurs.

The userInfo dictionary of this notification contains the AVAudioSessionInterruptionTypeKey. If the interruption type is AVAudioSessionInterruptionTypeEnded, this dictionary also contains the AVAudioSessionInterruptionOptionKey key. This notification is posted on the main thread of your app.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVAudioSession.h 


delegate 를 사용하지 않고 NSNotificationCenter 를 이용하는 방법으로 변경!


그래서 NSNotificationCenter에 AVAudioSesssionInterruptionNotification observer를 등록하고, 여러번의 테스트 진행....


ㅠㅠ

ㅠㅠ

ㅠㅠ


iOS6.0 이 설치된 device 에서 begin interruption 상황에서 Notification 이 들어오질 않는다!!!!! (음악 듣다가 전화오면 배경으로 음악이 깔림 읭ㅋ?)


뭘 잘못했을까하고... 삽질에 삽질....


그래서 AVAudioSession 사용을 버리기로하고,


AudioToolbox framework의 CF계열의 AudioSession 관리 함수들을 사용하기로 결정... (자세한 사용법은 생략)


그래도! 여전히 마찬가지로 "BEGIN INTERRUPTION" 에서의 CALLBACK 함수가 호출이 안됨 ㅠㅠ


포기상태로, 구글링과 stackoverflow 형들의 article을 읽어보기 시작.....


버그란다... ㅠㅠ 


아! 애플형들... ㅠㅠ 이럴수가...


얼른 iOS6.0.1 SDK가 나오길 바란다.... (그전까지 재생중 전화오면 배경음악으로 나오는거지 뭐~ ㅋㅋ)








공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함