[Video] More tweaks to AVAudioSession options (#4910)

This commit is contained in:
Hailey 2024-08-09 14:35:26 -07:00 committed by GitHub
parent dd0d50a6f0
commit 5bfe5aa503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 74 additions and 10 deletions

View file

@ -1,6 +1,8 @@
import {Platform} from 'react-native'
import {requireNativeModule} from 'expo-modules-core'
import {AudioCategory} from './types'
const NativeModule = requireNativeModule('ExpoPlatformInfo')
export function getIsReducedMotionEnabled(): boolean {
@ -11,3 +13,8 @@ export function setAudioMixWithOthers(mixWithOthers: boolean): void {
if (Platform.OS !== 'ios') return
NativeModule.setAudioMixWithOthers(mixWithOthers)
}
export function setAudioCategory(audioCategory: AudioCategory): void {
if (Platform.OS !== 'ios') return
NativeModule.setAudioCategory(audioCategory)
}

View file

@ -1,9 +1,23 @@
import {NotImplementedError} from '../NotImplemented'
import {AudioCategory} from './types'
export function getIsReducedMotionEnabled(): boolean {
throw new NotImplementedError()
}
/**
* Set whether the app's audio should mix with other apps' audio.
* @param mixWithOthers
*/
export function setAudioMixWithOthers(mixWithOthers: boolean): void {
throw new NotImplementedError({mixWithOthers})
}
/**
* Set the audio category for the app.
* @param audioCategory
* @platform ios
*/
export function setAudioCategory(audioCategory: AudioCategory): void {
throw new NotImplementedError({audioCategory})
}

View file

@ -1,4 +1,5 @@
import {NotImplementedError} from '../NotImplemented'
import {AudioCategory} from './types'
export function getIsReducedMotionEnabled(): boolean {
if (typeof window === 'undefined') {
@ -10,3 +11,7 @@ export function getIsReducedMotionEnabled(): boolean {
export function setAudioMixWithOthers(mixWithOthers: boolean): void {
throw new NotImplementedError({mixWithOthers})
}
export function setAudioCategory(audioCategory: AudioCategory): void {
throw new NotImplementedError({audioCategory})
}

View file

@ -0,0 +1,15 @@
/**
* Sets the audio session category on iOS. In general, we should only need to use this for the `playback` and `ambient`
* categories. This enum however includes other categories that are available in the native API for clarity and
* potential future use.
* @see https://developer.apple.com/documentation/avfoundation/avaudiosession/category
* @platform ios
*/
export enum AudioCategory {
Ambient = 'AVAudioSessionCategoryAmbient',
Playback = 'AVAudioSessionCategoryPlayback',
_SoloAmbient = 'AVAudioSessionCategorySoloAmbient',
_Record = 'AVAudioSessionCategoryRecord',
_PlayAndRecord = 'AVAudioSessionCategoryPlayAndRecord',
_MultiRoute = 'AVAudioSessionCategoryMultiRoute',
}