Share
Embed
Transcript
24 slides
-
entaku • Name: entaku • Job: iOS/AndroidΤϯδχΞͳͲ • SIer6 •
εϙʔπϚονϯάΞϓϦ1 • ྲྀITαʔϏε 2 • Voicy ->New • Twitter • @entaku_0818 -
AVAudioSession ͷαϯϓϧίʔυ /// Set session category. @available(iOS 3.0, *) open
func setCategory(_ category: AVAudioSession.Category) throws /// Set session category with options. @available(iOS 6.0, *) open func setCategory(_ category: AVAudioSession.Category, options: AVAudioSession.CategoryOptions = []) throws /// Set session category and mode with options. @available(iOS 10.0, *) open func setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode, options: AVAudioSession.CategoryOptions = []) throws -
AVAudioSession ͷαϯϓϧίʔυ /// Set session category. @available(iOS 3.0, *) open
func setCategory(_ category: AVAudioSession.Category) throws /// Set session category with options. @available(iOS 6.0, *) open func setCategory(_ category: AVAudioSession.Category, options: AVAudioSession.CategoryOptions = []) throws /// Set session category and mode with options. @available(iOS 10.0, *) open func setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode, options: AVAudioSession.CategoryOptions = []) throws • VoicyͰར༻ -
AVAudioSession - category • soloAmbient • ΦʔσΟΦΛόοΫάϥϯυΦʔσΟΦͱϛοΫε͠ͳ͍ΞϓϦ༻ʢσϑΥϧτʣ ͷΧςΰϦͰ͢ɻ • ambient
• ΦʔσΟΦΛόοΫάϥϯυΦʔσΟΦͱϛοΫε͢ΔΞϓϦ༻ʢϘλϯԻ ΧʔφϏԻҊͷΈͳͲʣͷΧςΰϦͰ͢ɻ • playback • ΦʔσΟΦ࠶ੜ༻ͷΧςΰϦͰ͢ɻ • record • ΦʔσΟΦԻ༻ͷΧςΰϦͰ͢ɻ https://developer.apple.com/documentation/avfaudio/avaudiosession/category -
AVAudioSession - category • playAndRecord • ΦʔσΟΦ࠶ੜͱԻΛ྆ํߦ͏ΞϓϦ༻ʢVoIPͳͲʣͷΧςΰϦͰ͢ɻ • multiRoute •
ΦʔσΟΦΛҟͳΔσόΠεʹಉ࣌ग़ྗ͢ΔΞϓϦ༻ͷΧςΰϦͰ͢ɻ https://developer.apple.com/documentation/avfaudio/avaudiosession/category -
AVAudioSession - Mode • default • σϑΥϧτͷϞʔυͰ͢ɻ • gameChat •
ήʔϜνϟοτͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ • measurement • ΦʔσΟΦೖग़ྗͷଌఆͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ • moviePlayback • өը࠶ੜͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ https://developer.apple.com/documentation/avfaudio/avaudiosession/category -
AVAudioSession - Mode • spokenAudio • ԻͷׂΓࠐΈ͕͋ΔΞϓϦͰͷར༻Λࣔ͢ϞʔυͰ͢ɻΧʔφϏԻҊͳͲɺׂ͍ΓࠐΈͷࡍʹ࠶ੜதͷ ͷΛҰ࣌ఀࢭ͠ɺऴΘΓ࣍ୈ࠶։͠·͢ɻ • videoChat
• ΦϯϥΠϯϏσΦձٞͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ • videoRecording • ಈըըͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ • voiceChat • VoIPͳͲͷํͷԻ௨৴Ͱͷར༻Λࣔ͢ϞʔυͰ͢ɻ • voicePrompt • ςΩετಡΈ্͛Λ༻ͨ͠Ի࠶ੜͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/ -
AVAudioSession - Option • mixWithOthers • ΦʔσΟΦ͕όοΫάϥϯυΦʔσΟΦͱϛοΫε͢Δ͜ͱΛࣔ͢Φϓγϣϯɻ • duckOthers •
ΦʔσΟΦ࠶ੜ࣌ʹɺόοΫάϥϯυΦʔσΟΦͷԻྔΛԼ͛ΔΦϓγϣϯɻ • InterruptSpokenAudioAndMixWithOthers • ΦʔσΟΦΛ࠶ੜ࣌ʹɺόοΫάϥϯυΦʔσΟΦΛҰ࣌ఀࢭ͢Δ͔Ͳ͏͔Λܾఆ͢ΔΦ ϓγϣϯɻ • allowBluetooth • BluetoothϋϯζϑϦʔσόΠεΛ༻Մೳͳೖྗϧʔτͱͯ͠දࣔ͢Δ͔Ͳ͏͔Λܾఆ͢Δ Φϓγϣϯɻ https://developer.apple.com/documentation/avfaudio/avaudiosession/ categoryoptions -
AVAudioSession - Option • spokenAudio • ԻͷׂΓࠐΈ͕͋ΔΞϓϦͰͷར༻Λࣔ͢ϞʔυͰ͢ɻΧʔφϏԻҊͳͲɺׂ͍ΓࠐΈͷࡍʹ࠶ੜதͷ ͷΛҰ࣌ఀࢭ͠ɺऴΘΓ࣍ୈ࠶։͠·͢ɻ • videoChat
• ΦϯϥΠϯϏσΦձٞͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ • videoRecording • ಈըըͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ • voiceChat • VoIPͳͲͷํͷԻ௨৴Ͱͷར༻Λࣔ͢ϞʔυͰ͢ɻ • voicePrompt • ςΩετಡΈ্͛Λ༻ͨ͠Ի࠶ੜͰͷར༻Λࣔ͢ϞʔυͰ͢ɻ https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions -
AVAudioSession ͷαϯϓϧίʔυ ɹɹɹɹɹtry? audioSession.setCategory(AVAudioSession.Category.playback) OR ɹɹɹɹɹtry? audioSession.setCategory(AVAudioSession.Category.soloAmbient) OR ɹɹɹɹ// background
try? audioSession.setCategory(AVAudioSession.Category.ambient, options: AVAudioSession.CategoryOptions.mixWithOthers) ※ίʔυΠϝʔδͰ͢ -
backGround͔Ͳ͏͔ͷఆ ɹɹɹɹɹif (secondaryAudioShouldBeSilencedHint){ ɹ// background try? audioSession.setCategory(AVAudioSession.Category.ambient, options: AVAudioSession.CategoryOptions.mixWithOthers) }else{
// forground // Ϣʔβʔͷঢ়ଶʹΑ͍͚ͬͯ try? audioSession.setCategory(AVAudioSession.Category.playback) OR ɹɹɹɹɹtry? audioSession.setCategory(AVAudioSession.Category.soloAmbient) } ɹɹɹ ※ίʔυΠϝʔδͰ͢ -
backGround͔Ͳ͏͔ͷఆ https://developer.apple.com/documentation/avfaudio/avaudiosession/1616600-secondaryaudioshouldbesilencedhi • This property returns true if any other
audio is playing, including audio from an app using the ambient category. Most apps should instead use the secondaryAudioShouldBeSilencedHint property, because it’s more restrictive when considering whether primary audio from another app is playing. https://developer.apple.com/documentation/avfaudio/avaudiosession/1616610-isotheraudioplaying • secondaryAudioShouldBeSilencedHintΛ ͏