0.9.21 • Published 3 years ago

@skylabs_technology/capacitor-mixer v0.9.21

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Mixer Plugin by Skylabs Technology

Android

Usage

Minimum target deployment: 28

to set this value you can add this to your ./android/variables.gradle

ext {
    minSdkVersion = 28
}

Permissions

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="@string/custom_url_scheme" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.OPEN_DOCUMENT" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="io.ionic.starter" />
    <data android:mimeType="audio/*" />
</intent-filter>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>

API

requestMixerPermissions()

requestMixerPermissions() => Promise<BaseResponse<null>>

Requests permissions required by the mixer plugin

  • iOS: Permissions must be added to application in the Info Target Properties

  • Android: Permissions must be added to AndroidManifest.XML

See README for additional information on permissions

Returns: Promise<BaseResponse<null>>


addListener(string, ...)

addListener(eventName: string, listenerFunc: (response: AudioSessionEvent) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Adds listener for AudioSession events

Ex:

Register Listener:

Mixer.addListener("myEventName", this.myListenerFunction.bind(this));

myListenerFunction(response: <a href="#audiosessionevent">AudioSessionEvent</a>) { 
 // handle event 
}
ParamType
eventNamestring
listenerFunc(response: AudioSessionEvent) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener(string, ...)

addListener(eventName: string, listenerFunc: (response: MixerTimeEvent) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Adds listener for audio track time update events

Ex:

Register Listener:

Mixer.addListener("myEventName", this.myListenerFunction.bind(this));

myListenerFunction(response: <a href="#mixertimeevent">MixerTimeEvent</a>) { 
 // handle event 
}
ParamType
eventNamestring
listenerFunc(response: MixerTimeResponse) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener(string, ...)

addListener(eventName: string, listenerFunc: (response: VolumeMeterEvent) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Adds listener for volume metering update events

Ex:

Register Listener:

Mixer.addListener("myEventName", this.myListenerFunction.bind(this));

myListenerFunction(response: <a href="#volumemeterevent">VolumeMeterEvent</a>) { 
 // handle event 
}
ParamType
eventNamestring
listenerFunc(response: VolumeMeterEvent) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


playOrPause(...)

playOrPause(request: BaseMixerRequest) => Promise<BaseResponse<PlaybackStateResponse>>

Toggles playback and pause on an initialized audio file

ParamType
requestBaseMixerRequest

Returns: Promise<BaseResponse<PlaybackStateResponse>>


stop(...)

stop(request: BaseMixerRequest) => Promise<BaseResponse<PlaybackStateResponse>>

Stops playback on a playing audio file

ParamType
requestBaseMixerRequest

Returns: Promise<BaseResponse<PlaybackStateResponse>>


isPlaying(...)

isPlaying(request: BaseMixerRequest) => Promise<BaseResponse<IsPlayingResponse>>

A boolean that returns the playback state of initialized audio file

ParamType
requestBaseMixerRequest

Returns: Promise<BaseResponse<IsPlayingResponse>>


getCurrentVolume(...)

getCurrentVolume(request: ChannelPropertyRequest) => Promise<BaseResponse<VolumeResponse>>

Returns current volume of a channel as a number between 0 and 1

ParamType
requestChannelPropertyRequest

Returns: Promise<BaseResponse<VolumeResponse>>


getCurrentEq(...)

getCurrentEq(request: ChannelPropertyRequest) => Promise<BaseResponse<EqResponse>>

Returns an object with numeric values for gain and frequency in bass, mid, and treble ranges

ParamType
requestChannelPropertyRequest

Returns: Promise<BaseResponse<EqResponse>>


initAudioFile(...)

initAudioFile(request: InitChannelRequest) => Promise<BaseResponse<InitResponse>>

Returns AudioId string of initialized audio file

ParamType
requestInitChannelRequest

Returns: Promise<BaseResponse<InitResponse>>


adjustVolume(...)

adjustVolume(request: AdjustVolumeRequest) => Promise<BaseResponse<null>>

Adjusts volume for a channel

ParamType
requestAdjustVolumeRequest

Returns: Promise<BaseResponse<null>>


adjustEq(...)

adjustEq(request: AdjustEqRequest) => Promise<BaseResponse<null>>

Adjusts gain and frequency in bass, mid, and treble ranges for a channel

ParamType
requestAdjustEqRequest

Returns: Promise<BaseResponse<null>>


setElapsedTimeEvent(...)

setElapsedTimeEvent(request: SetEventRequest) => Promise<BaseResponse<null>>

Sets an elapsed time event name for a given audioId. To unset elapsedTimeEvent pass an empty string and this will stop the event from being triggered.

Only applicable for audio files

ParamType
requestSetEventRequest

Returns: Promise<BaseResponse<null>>


getElapsedTime(...)

getElapsedTime(request: BaseMixerRequest) => Promise<BaseResponse<MixerTimeResponse>>

Returns an object representing hours, minutes, seconds, and milliseconds elapsed

ParamType
requestBaseMixerRequest

Returns: Promise<BaseResponse<MixerTimeResponse>>


getTotalTime(...)

getTotalTime(request: BaseMixerRequest) => Promise<BaseResponse<MixerTimeResponse>>

Returns total time in an object of hours, minutes, seconds, and millisecond totals

ParamType
requestBaseMixerRequest

Returns: Promise<BaseResponse<MixerTimeResponse>>


initMicInput(...)

initMicInput(request: InitChannelRequest) => Promise<BaseResponse<InitResponse>>

Initializes microphone channel on mixer

Returns AudioId string of initialized microphone input

ParamType
requestInitChannelRequest

Returns: Promise<BaseResponse<InitResponse>>


getInputChannelCount()

getInputChannelCount() => Promise<BaseResponse<ChannelCountResponse>>

Returns the channel count and name of the initialized audio device

Returns: Promise<BaseResponse<ChannelCountResponse>>


initAudioSession(...)

initAudioSession(request: InitAudioSessionRequest) => Promise<BaseResponse<InitAudioSessionResponse>>

Initializes audio session with selected port type,

Returns a value describing the initialized port type for the audio session (usb, built-in, etc.)

ParamType
requestInitAudioSessionRequest

Returns: Promise<BaseResponse<InitAudioSessionResponse>>


deinitAudioSession()

deinitAudioSession() => Promise<BaseResponse<null>>

Cancels audio session and resets selected port. Use prior to changing port type

Returns: Promise<BaseResponse<null>>


checkAudioSessionState()

checkAudioSessionState() => Promise<BaseResponse<SessionStateResponse>>

Checks the current state of the AudioSession.

Returns: Promise<BaseResponse<SessionStateResponse>>


resetPlugin()

resetPlugin() => Promise<BaseResponse<null>>

Resets plugin state back to its initial state

<span style="color: 'red'">CAUTION: This will completely wipe everything you have initialized from the plugin!</span>

Returns: Promise<BaseResponse<null>>


getAudioSessionPreferredInputPortType()

getAudioSessionPreferredInputPortType() => Promise<BaseResponse<InitResponse>>

Returns a value describing the initialized port type for the audio session (usb, built-in, etc.)

Returns: Promise<BaseResponse<InitResponse>>


destroyMicInput(...)

destroyMicInput(request: BaseMixerRequest) => Promise<BaseResponse<DestroyResponse>>

De-initializes a mic input channel based on audioId

Note: Once destroyed, the channel cannot be recovered

ParamTypeDescription
requestBaseMixerRequestaudioId

Returns: Promise<BaseResponse<DestroyResponse>>


destroyAudioFile(...)

destroyAudioFile(request: BaseMixerRequest) => Promise<BaseResponse<DestroyResponse>>

De-initializes an audio file channel based on audioId

Note: Once destroyed, the channel cannot be recovered

ParamTypeDescription
requestBaseMixerRequestaudioId

Returns: Promise<BaseResponse<DestroyResponse>>


validateFileUri(...)

validateFileUri(request: FileValidationRequest) => Promise<BaseResponse<FileValidationResponse>>

Validates file path and returns true if valid, false if invalid

ParamType
requestFileValidationRequest

Returns: Promise<BaseResponse<FileValidationResponse>>


startStream(...)

startStream(request: StreamRequest) => Promise<BaseResponse<null>>

Starts a stream to a provided URL

ParamType
requestStreamRequest

Returns: Promise<BaseResponse<null>>


stopStream()

stopStream() => Promise<BaseResponse<null>>

Stops a stream if one is currently active.

Returns: Promise<BaseResponse<null>>


Interfaces

BaseResponse

The response wrapper for all response objects

PropTypeDescription
statusResponseStatusStatus of returned request. Ex: 'SUCCESS', 'ERROR'
messagestringMessage that describes response Note: Can be used for user messages
dataTResponse data object field Ex: A MixerTimeResponse object

PluginListenerHandle

PropType
remove() => Promise<void>

AudioSessionEvent

Event response for handling audio session notifications

PropTypeDescription
handlerTypeAudioSessionHandlerTypesThe event type that occurred

MixerTimeResponse

Response representing HH:MM:SS.ms-formatted time

PropTypeDescription
milliSecondsnumberms in formatted time
secondsnumberSS in formatted time
minutesnumberMM in formatted time
hoursnumberHH in formatted time

VolumeMeterEvent

Event response for handling current volume level

PropTypeDescription
meterLevelnumberCalculated amplitude in dB - Range: -80 to 0 dB

PlaybackStateResponse

Response that returns PlayerState

PropTypeDescription
statePlayerStateRepresents the state of the player

BaseMixerRequest

Base class for all mixer requests, consists of audioId only

PropTypeDescription
audioIdstringA string identifying the audio file or microphone channel instance

IsPlayingResponse

Response for tracking player state as a boolean

PropTypeDescription
valuebooleanValue of tracked player state

VolumeResponse

Response for tracking channel volume

PropTypeDescription
volumenumberValue of tracked channel volume

ChannelPropertyRequest

Request to get info about channel properties such as current volume, EQ, etc.

PropTypeDescription
inputTypeInputTypeType of input on which properties are being requested

EqResponse

Response for tracking channel EQ

PropTypeDescription
bassGainnumberBass gain for channel - Range: -36 to +15 dB
bassFrequencynumberBass frequency for channel - Suggested range: 20Hz to 499Hz
midGainnumberMid gain for channel - Range: -36 to +15 dB
midFrequencynumberMid frequency for channel - Suggested range: 500Hz to 1499Hz
trebleGainnumberTreble gain for channel - Range: -36 to +15 dB
trebleFrequencynumberTreble frequency for channel - Suggested range: 1.5kHz to 20kHz

InitResponse

Response for initialization of channel

PropTypeDescription
valuestringInitialized channel audioId

InitChannelRequest

Request used to initialize a channel on the mixer

PropTypeDescription
filePathstringA string identifying the path to the audio file on device. Unused if initializing microphone channel
elapsedTimeEventNamestringA string identifying the elapsed time event name. This will automatically set the event and setElapsedTimeEvent is not needed. Unused if initializing microphone channel
channelNumbernumberThe channel number being initialized for microphone. Starts at 0. Unused if initializing audio file
bassGainnumberOptional bass gain setting for initialization: -36dB to +15 dB Default: 0dB
bassFrequencynumberOptional init eq setting for bass EQ band iOS Default: 115Hz Android Default: 200Hz
midGainnumberOptional mid gain setting for initialization: -36dB to +15 dB Default: 0dB
midFrequencynumberOptional init setting for mid EQ band iOS Default: 500Hz Android Default: 1499Hz
trebleGainnumberOptional treble gain setting for initialization: -36dB to +15 dB Default: 0dB
trebleFrequencynumberOptional init eq setting for treble EQ band iOS Default: 1.5kHz Android Default: 20kHz
volumenumberOptional init setting for volume Default: 1 Range: 0 - 1
channelListenerNamestringRequired name used to set listener for volume metering Subscribed event returns VolumeMeterEvent Note: if empty string is passed, metering will be disabled on channel

AdjustVolumeRequest

For mixer requests manipulating volume level

PropTypeDescription
volumenumberA number between 0 and 1 specifying volume level being set
inputTypeInputTypeType of input on which volume is being adjusted

AdjustEqRequest

For mixer requests manipulating EQ

PropTypeDescription
eqTypeEqTypeIdentifies EQ band to adjust: Bass, Mid, Treble
gainnumberA number between -36dB and +15dB identifying EQ band gain
frequencynumberA number identifying cutoff/central frequency for EQ band Bass: - iOS implemented as a low shelf - Android implemented as a high pass filter Mid: - implemented as a parametric 'bump' Treble: - iOS implemented as a high shelf - Android implemented as a low pass filter
inputTypeInputTypeType of input on which EQ is being adjusted

SetEventRequest

Request to set an event listener

PropTypeDescription
eventNamestringThe name of the event that will be subscribed to Subscribed event returns MixerTimeEvent

ChannelCountResponse

Response for channel count of requested audio port

PropTypeDescription
channelCountnumberNumber of channels found
deviceNamestringName of the device at the requested audio port

InitAudioSessionResponse

Response for initalizing audio session

PropTypeDescription
preferredInputPortTypeAudioSessionPortTypeType found when initializing audio session
preferredInputPortNamestringDevice name found when initializing audio session
preferredIOBufferDurationnumberiOS only Preferred buffer duration when initializing audio session

InitAudioSessionRequest

Request to initialize an audio session

PropTypeDescription
inputPortTypeAudioSessionPortTypeAn enum describing input hardware device to be used
ioBufferDurationnumberiOS only The preferred duration of the input buffer (0.05 recommended as a starting point, change may be observed as output latency)
audioSessionListenerNamestringThe name of the audio session event that will be subscribed to. Subscribed event returns AudioSessionEvent

SessionStateResponse

Response that returns PlayerState

PropTypeDescription
statebooleanRepresents the state of the player

DestroyResponse

Response for destroying a channel

PropTypeDescription
listenerNamestringThe name of the volume metering event Note: If no event is found, empty string is returned
elapsedTimeEventNamestringThe name of the elapsed time event Note: If no event is found, empty string is returned

FileValidationResponse

Response for validating file path

PropTypeDescription
isFileValidbooleanTrue if file path is found, False if file path is not found
filePathstringFile path that was checked.

FileValidationRequest

Request to validate a file path.

PropTypeDescription
filePathstringThe file path that will be validated.

StreamRequest

Request to stream audio to provided url

PropType
streamUrlstring

Type Aliases

MixerTimeEvent

Event response for handling current elapsed time

MixerTimeResponse

PlayerState

Possible states of player

"play" | "pause" | "stop" | "not implemented"

Enums

ResponseStatus

MembersValue
SUCCESS"success"
ERROR"error"

AudioSessionHandlerTypes

MembersValueDescription
INTERRUPT_BEGAN"INTERRUPT_BEGAN"Invoked when another audio session has started This can cause your audio to be 'ducked', or silenced with the audio session
INTERRUPT_ENDED"INTERRUPT_ENDED"Invoked when another audio session has ended Your audio session should resume
ROUTE_DEVICE_DISCONNECTED"ROUTE_DEVICE_DISCONNECTED"Invoked when the device you're currently connected to is disconnected from the audio session
ROUTE_DEVICE_RECONNECTED"ROUTE_DEVICE_RECONNECTED"Invoked when previously-used device is reconnected to the audio session
ROUTE_NEW_DEVICE_FOUND"ROUTE_NEW_DEVICE_FOUND"Invoked when previously-UNUSED device is connected to the audio session

InputType

MembersValue
MIC"mic"
FILE"file"

EqType

MembersValue
BASS"bass"
MID"mid"
TREBLE"treble"

AudioSessionPortType

MembersValueDescription
HDMI"hdmi"
AIRPLAY"airplay"iOS only
BLUETOOTH_A2DP"bluetoothA2DP"
BLUETOOTH_HFP"bluetoothHFP"
BLUETOOTH_LE"bluetoothLE"iOS only
BUILT_IN_MIC"builtInMic"
HEADSET_MIC_WIRED"headsetMicWired"iOS only
HEADSET_MIC_USB"headsetMicUsb"
LINE_IN"lineIn"
THUNDERBOLT"thunderbolt"iOS only
USB_AUDIO"usbAudio"
VIRTUAL"virtual"
0.9.21

3 years ago

0.9.20

3 years ago

0.9.16

3 years ago

0.9.17

3 years ago

0.9.18

3 years ago

0.9.19

3 years ago

0.9.12

3 years ago

0.9.13

3 years ago

0.9.14

3 years ago

0.9.15

3 years ago

0.9.9

3 years ago

0.9.10

3 years ago

0.9.11

3 years ago

0.9.8

3 years ago

0.9.7

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.6

3 years ago

0.9.5

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago