1 | import ExponentAV from '../ExponentAV';
|
2 |
|
3 | let _enabled = true;
|
4 |
|
5 | export function isAudioEnabled(): boolean {
|
6 | return _enabled;
|
7 | }
|
8 |
|
9 | export function throwIfAudioIsDisabled(): void {
|
10 | if (!_enabled) {
|
11 | throw new Error('Cannot complete operation because audio is not enabled.');
|
12 | }
|
13 | }
|
14 |
|
15 | export async function setIsEnabledAsync(value: boolean): Promise<void> {
|
16 | _enabled = value;
|
17 | await ExponentAV.setAudioIsEnabled(value);
|
18 | // TODO : We immediately pause all players when disabled, but we do not resume all shouldPlay
|
19 | // players when enabled. Perhaps for completeness we should allow this; the design of the
|
20 | // enabling API is for people to enable / disable this audio library, but I think that it should
|
21 | // intuitively also double as a global pause/resume.
|
22 | }
|