[Videos] Add iOS function to set `AVAudioSession.CategoryOptions` to `.mixWithOthers` (#4905)
* audio mixing pref * lintzio/stable
parent
a4f0c9c753
commit
cb574b7be3
|
@ -7,5 +7,15 @@ public class ExpoPlatformInfoModule: Module {
|
||||||
Function("getIsReducedMotionEnabled") {
|
Function("getIsReducedMotionEnabled") {
|
||||||
return UIAccessibility.isReduceMotionEnabled
|
return UIAccessibility.isReduceMotionEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function("setAudioMixWithOthers") { (mixWithOthers: Bool) in
|
||||||
|
var options: AVAudioSession.CategoryOptions
|
||||||
|
if mixWithOthers {
|
||||||
|
options = [.mixWithOthers]
|
||||||
|
} else {
|
||||||
|
options = []
|
||||||
|
}
|
||||||
|
try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: .default, options: options)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import {Platform} from 'react-native'
|
||||||
import {requireNativeModule} from 'expo-modules-core'
|
import {requireNativeModule} from 'expo-modules-core'
|
||||||
|
|
||||||
const NativeModule = requireNativeModule('ExpoPlatformInfo')
|
const NativeModule = requireNativeModule('ExpoPlatformInfo')
|
||||||
|
@ -5,3 +6,8 @@ const NativeModule = requireNativeModule('ExpoPlatformInfo')
|
||||||
export function getIsReducedMotionEnabled(): boolean {
|
export function getIsReducedMotionEnabled(): boolean {
|
||||||
return NativeModule.getIsReducedMotionEnabled()
|
return NativeModule.getIsReducedMotionEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setAudioMixWithOthers(mixWithOthers: boolean): void {
|
||||||
|
if (Platform.OS !== 'ios') return
|
||||||
|
NativeModule.setAudioMixWithOthers(mixWithOthers)
|
||||||
|
}
|
||||||
|
|
|
@ -3,3 +3,7 @@ import {NotImplementedError} from '../NotImplemented'
|
||||||
export function getIsReducedMotionEnabled(): boolean {
|
export function getIsReducedMotionEnabled(): boolean {
|
||||||
throw new NotImplementedError()
|
throw new NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setAudioMixWithOthers(mixWithOthers: boolean): void {
|
||||||
|
throw new NotImplementedError({mixWithOthers})
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
|
import {NotImplementedError} from '../NotImplemented'
|
||||||
|
|
||||||
export function getIsReducedMotionEnabled(): boolean {
|
export function getIsReducedMotionEnabled(): boolean {
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
return window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setAudioMixWithOthers(mixWithOthers: boolean): void {
|
||||||
|
throw new NotImplementedError({mixWithOthers})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue