|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +--- |
| 4 | + |
| 5 | +import { Optional, ReadOnly } from '@site/src/components/Badges'; |
| 6 | + |
| 7 | +# AudioManager |
| 8 | + |
| 9 | +The `AudioManager` is a layer of an abstraction between user and a system. |
| 10 | +It provides a set of system-specific functions that are invoked directly in native code, by related system. |
| 11 | + |
| 12 | +## Properties |
| 13 | + |
| 14 | +| Name | Type | Description | |
| 15 | +| :----: | :----: | :-------- | |
| 16 | +| `audioEventEmitter` <ReadOnly /> | `AudioEventEmitter` | Custom event emmiter that allows to create listener, to events that are invoked from a system. | |
| 17 | + |
| 18 | +## Methods |
| 19 | + |
| 20 | +### `setLockScreenInfo` |
| 21 | + |
| 22 | +| Parameters | Type | |
| 23 | +| :---: | :---: | |
| 24 | +| `info` | [`LockScreenInfo`](/system/audio-manager#lockscreeninfo) | |
| 25 | + |
| 26 | +### `resetLockScreenInfo` |
| 27 | + |
| 28 | +Resets all of the lock screen data. |
| 29 | + |
| 30 | +### `setAudioSessionOptions` |
| 31 | + |
| 32 | +| Parameters | Type | Description | |
| 33 | +| :---: | :---: | :---- | |
| 34 | +| options `iOS` only | [`SessionOptions`](/system/audio-manager#sessionoptions) | Options to be set for session | |
| 35 | + |
| 36 | +### `getDevicePreferredSampleRate` |
| 37 | + |
| 38 | +Returns preferred sample rate by the device. |
| 39 | + |
| 40 | +### `observeAudioInterruptions` |
| 41 | + |
| 42 | +| Parameters | Type | Description | |
| 43 | +| :---: | :---: | :---- | |
| 44 | +| `enabled` | `boolean` | Can be used to enable or disable observing audio interruptions | |
| 45 | + |
| 46 | +### `observeVolumeChanges` |
| 47 | + |
| 48 | +| Parameters | Type | Description | |
| 49 | +| :---: | :---: | :---- | |
| 50 | +| `enabled` | `boolean` | Can be used to enable or disable observing volume changes | |
| 51 | + |
| 52 | +### `enableSystemEvent` |
| 53 | + |
| 54 | +| Parameters | Type | Description | |
| 55 | +| :---: | :---: | :---- | |
| 56 | +| `name` | [`Name`](/system/audio-manager#name) | Name of an event listener | |
| 57 | +| `callback` <Optional /> | [`SystemEventCallback<Name>`](/system/audio-manager#systemeventcallbackname) | Callback that will be invoked upon hearing an event | |
| 58 | +| `enabled` | `boolean` (default value is `true`)| Can be used to enable or disable emmiting system event | |
| 59 | + |
| 60 | +### `requestRecordingPermissions` |
| 61 | + |
| 62 | +Allows to bring up the system microphone permissions pop-up on demand. The pop-up automatically shows if microphone data |
| 63 | +is directly requested, but sometimes it is better to ask beforehand. |
| 64 | +Returns promise of [`PermissionStatus`](/system/audio-manager#permissionstatus) type, which is resolved after receiving answer from the system. |
| 65 | + |
| 66 | +### `checkRecordingPermissions` |
| 67 | + |
| 68 | +Allows to check if permissions were previously granted. |
| 69 | +Returns promise of [`PermissionStatus`](/system/audio-manager#permissionstatus) type, which is resolved after receiving answer from the system. |
| 70 | + |
| 71 | +## Remarks |
| 72 | + |
| 73 | +### `LockScreenInfo` |
| 74 | + |
| 75 | +| Name | Type | Description | |
| 76 | +| :----: | :----: | :-------- | |
| 77 | +| `title` <Optional /> | `string` | Title of the track | |
| 78 | +| `artwork` <Optional /> | `string` | Uri to the artwork | |
| 79 | +| `artist` <Optional /> | `string` | Name of the artist | |
| 80 | +| `album` <Optional /> | `string` | Name of the album | |
| 81 | +| `duration` <Optional /> | `number` | Duration of the song in seconds | |
| 82 | +| `description` <Optional /> `android` only | `string` | Description of the track | |
| 83 | +| `state` <Optional /> | `string` | `state_playing` if track is played, `state_paused` otherwise | |
| 84 | +| `speed` <Optional /> | `number` | Speed rate of playing | |
| 85 | +| `elapsedTime` <Optional /> | `number` | In seconds, how many time of audio has elapsed | |
| 86 | + |
| 87 | +### `SessionOptions` |
| 88 | + |
| 89 | +| Name | Type | Possible values | |
| 90 | +| :----: | :----: | :-------- | |
| 91 | +| `iosMode` <Optional /> | `string` | `default`, `gameChat`, `videoChat`, `voiceChat`, `measurement`, `voicePrompt`, `spokenAudio`, `moviePlayback`, `videoRecording`| |
| 92 | +| `iosOptions` <Optional /> | `string[]` | `duckOthers`, `allowAirPlay`, `mixWithOthers`, `allowBluetooth`, `defaultToSpeaker`, `allowBluetoothA2DP`, `overrideMutedMicrophoneInterruption`, `interruptSpokenAudioAndMixWithOthers`| |
| 93 | +| `iosCategory` <Optional /> | `string` | `record`, `ambient`, `playback`, `multiRoute`, `soloAmbient`, `playAndRecord`| |
| 94 | + |
| 95 | + |
| 96 | +### `Name` |
| 97 | + |
| 98 | +TODO: description of what each of the name does |
| 99 | + |
| 100 | + |
| 101 | +Available values: |
| 102 | +- `remotePlay` |
| 103 | +- `remotePause` |
| 104 | +- `remoteStop` |
| 105 | +- `remoteTogglePlayPause` |
| 106 | +- `remoteChangePlaybackRate` |
| 107 | +- `remoteNextTrack` |
| 108 | +- `remotePreviousTrack` |
| 109 | +- `remoteSkipForward` |
| 110 | +- `remoteSkipBackward` |
| 111 | +- `remoteSeekForward` |
| 112 | +- `remoteSeekBackward` |
| 113 | +- `remoteChangePlaybackPosition` |
| 114 | +- `volumeChange` |
| 115 | +- `interruption` |
| 116 | +- `routeChange` |
| 117 | + |
| 118 | + |
| 119 | +### `SystemEventCallback<Name>` |
| 120 | + |
| 121 | +It maps `Name` value to a corresponding type of callback. |
| 122 | + |
| 123 | +- `remotePlay`, `remotePause`, `remoteStop`, `remoteTogglePlayPause`, `remoteNextTrack`, `remoteSkipForward`, `remoteSkipBackward` |
| 124 | + |
| 125 | +`Empty` type |
| 126 | + |
| 127 | +- `remoteChangePlaybackRate`, `remoteSeekForward`, `remoteSeekBackward`, `remoteChangePlaybackPosition`, `volumeChange` |
| 128 | + |
| 129 | +| Parameters | Type | Description | |
| 130 | +| :---: | :---: | :---- | |
| 131 | +| `value` | `number` | value from system described in [`Name`](/system/audio-manager#name) section |
| 132 | + |
| 133 | +- `interruption` |
| 134 | + |
| 135 | +| Parameters | Type | Description | |
| 136 | +| :---: | :---: | :---- | |
| 137 | +| `type` | `string` | `began` or `ended` value that indicates if interruption event has started or ended | |
| 138 | +| `shouldResume` | `boolean` | if we should resume playing upon receiving event | |
| 139 | + |
| 140 | +- `routeChange` |
| 141 | + |
| 142 | +| Parameters | Type | Description | |
| 143 | +| :---: | :---: | :---- | |
| 144 | +| `reason` | `string` | cause of event emition | |
| 145 | + |
| 146 | +### `PermissionStatus` |
| 147 | + |
| 148 | +Available `string` values: |
| 149 | +- `Denied` -> Indicates that user did not grant permission. |
| 150 | +- `Granted` -> Indicates that user did grant permission. |
| 151 | +- `Undetermined` -> In rare cases, system can return "not granted, but not denied" f.e. when something interrupt an app while asking. |
0 commit comments