///屬性記錄電話 打來(lái)中斷
private var centerPhone : CTCallCenter!
///電話進(jìn)來(lái) 暫停音樂(lè)和繼續(xù)音樂(lè)
private func phoneMusic() {
///監(jiān)聽(tīng)電話
centerPhone = CTCallCenter()
///設(shè)置回調(diào)
weak var weakSelf = self ///這里注意弱引用 避免循環(huán)
centerPhone.callEventHandler = { (call:CTCall) -> Void in
if call.callState == CTCallStateIncoming {
print("電話來(lái)了")
return
}
if call.callState == CTCallStateDisconnected {
print("電話結(jié)束了")
return
}
}
}
-
看我那么可愛(ài)n(≧▽≦)n
- 關(guān)注我的微薄 (梁同桌):http://weibo.com/tongrenyinsheng
- 個(gè)人網(wǎng)站(同人音聲) http://www.tongrenyinsheng.com
- ios 個(gè)人寫的app (同人音聲)ASMR音樂(lè)