Audio Management

An API to manage audio mode and volume.

Usage
AudioManagement.setAudioMode(AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        console.log(result);
    })
    .catch((error) => {
        console.error(error);
    });

...
    
AudioManagement.getMaxVolume(AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        AudioManagement.setVolume(
            AudioManagement.AudioMode.NORMAL,
            result.maxVolume / 2);
    })
    .catch((error) => {
        console.error(error);
    });
window.AudioManagement.setAudioMode(window.AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        console.log(result);
    })
    .catch((error) => {
        console.error(error);
    });

...

window.AudioManagement.getMaxVolume(window.AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        window.AudioManagement.setVolume(
            window.AudioManagement.AudioMode.NORMAL,
            result.maxVolume / 2
        );
    })
    .catch((error) => {
        console.error(error);
    });
window.AudioManagement.setAudioMode(window.AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        console.log(result);
    })
    .catch((error) => {
        console.error(error);
    });

...

window.AudioManagement.getMaxVolume(window.AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        window.AudioManagement.setVolume(window.AudioManagement.AudioMode.NORMAL,
        result.maxVolume / 2);
    })
    .catch((error) => {
        console.error(error);
    });
(<any>window).AudioManagement.setAudioMode((<any>window).AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        console.log(result);
    })
    .catch((error) => {
        console.error(error);
    });

...

(<any>window).AudioManagement.getMaxVolume((<any>window).AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        (<any>window).AudioManagement.setVolume(
            (<any>window).AudioManagement.AudioMode.NORMAL,
            result.maxVolume / 2
        );
    })
    .catch((error) => {
    console.error(error);
    });
window.AudioManagement.setAudioMode(window.AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        console.log(result);
    })
    .catch((error) => {
        console.error(error);
    });

...
                
window.AudioManagement.getMaxVolume(window.AudioManagement.AudioMode.NORMAL)
    .then((result) => {
        window.AudioManagement.setVolume(
            window.AudioManagement.AudioMode.NORMAL,
            result.maxVolume / 2
        );
    })
    .catch((error) => {
        console.error(error);
    });

Classes


AudioManagement

setAudioMode
setAudioMode(options: AudioMode): Promise<any>

Define the audio mode.


PARAMETERS
options: AudioMode

RETURN
returns: Promise <any>
getAudioMode
getAudioMode(): Promise<any>

Get the current audio mode.


RETURN
returns: Promise <any>
setVolume
setVolume(type: Type, volume: int): Promise<any>

Set the volume.


PARAMETERS
type: Type
volume: int 0 is the min volume level and the max volume level depends on the audio type. To know the highest volume of an audio type you can use the getMaxVolume function.

RETURN
returns: Promise <any>
getVolume
getVolume(type: Type): Promise<any>

Get the volume of a stream.


PARAMETERS
option: Type

RETURN
returns: Promise <any>
getMaxVolume
getMaxVolume(type: Type): Promise<any>

Get the max volume of a stream.


PARAMETERS
option: Type

RETURN
returns: Promise <any>

Enumerations

Audio Mode

enum AudioMode{
    SILENT : 0,
    VIBRATE: 1,
    NORMAL: 2
}

Volume Type

enum Type{
    RING : 0,
    MUSIC : 1,
    NOTIFICATION : 2,
    SYSTEM : 3
}