UNPKG

react-native-audio-api

Version:

react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification

50 lines 2.58 kB
import { AudioEventSubscription } from '../events'; import { SystemEventCallback, SystemEventName } from '../events/types'; import { AudioDevicesInfo, AudioFocusType, IAudioManager, PermissionStatus, SessionOptions } from './types'; declare class AudioManager implements IAudioManager { private readonly audioEventEmitter; constructor(); getDevicePreferredSampleRate(): number; /** * Activates or deactivates the audio session. * * Resolves when the session activity was set successfully. On failure it * rejects with a {@link SessionActivationError} carrying the native error * details (`nativeErrorInfo`) when available. */ setAudioSessionActivity(enabled: boolean): Promise<void>; setAudioSessionOptions(options: SessionOptions): void; disableSessionManagement(): void; observeAudioInterruptions(param: AudioFocusType | boolean | null): void; /** * @param enabled - Whether to actively reclaim the session or not * @experimental more aggressively try to reactivate the audio session during interruptions. * It is subject to change in the future and might be removed. * * In some cases (depends on app session settings and other apps using audio) system may never * send the `interruption ended` event. This method will check if any other audio is playing * and try to reactivate the audio session, as soon as there is "silence". * Although this might change the expected behavior. * * Internally method uses `AVAudioSessionSilenceSecondaryAudioHintNotification` as well as * interval polling to check if other audio is playing. */ activelyReclaimSession(enabled: boolean): void; observeVolumeChanges(enabled: boolean): void; addSystemEventListener<Name extends SystemEventName>(name: Name, callback: SystemEventCallback<Name>): AudioEventSubscription; requestRecordingPermissions(): Promise<PermissionStatus>; checkRecordingPermissions(): Promise<PermissionStatus>; requestNotificationPermissions(): Promise<PermissionStatus>; checkNotificationPermissions(): Promise<PermissionStatus>; getDevicesInfo(): Promise<AudioDevicesInfo>; /** * Selects the given device as the current audio input. * * Resolves when the input device was set successfully and rejects when the * device cannot be found or the system fails to switch to it. */ setInputDevice(deviceId: string): Promise<void>; } declare const _default: AudioManager; export default _default; //# sourceMappingURL=AudioManager.d.ts.map