Namespace: CB_AudioDetector

CB_AudioDetector

Static class to detect audio API and formats supported. Possible audio APIs are "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API). It will return itself if it is tried to be instantiated.

Source:

Methods


<static> APIExists(audioAPI [, sanitize]) → {boolean}

Returns whether a given audio API exists or not (without keeping into account whether it is supported or not). All existing ones are defined in CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS.

Parameters:
Name Type Argument Default Description
audioAPI string

The audio API that we want to check. All existing ones are defined in CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API).

sanitize boolean <optional>
true

If set to true, the "audioAPI" given will be trimmed and converted to upper case.

Source:
Returns:

Returns whether the given audio API exists or not (without keeping into account whether it is supported or not).

Type
boolean

<static> getPreferredAPI( [audioAPIs] [, allowEmulation] [, returnOnEmpty]) → {string|*}

Calculates and returns the preferred audio API (from an array if it is given) for the current client, if any.

Parameters:
Name Type Argument Default Description
audioAPIs array <optional>
CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS

An array of strings with the audio APIs that we want to check, in order of preference. All existing ones are defined in CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API).

allowEmulation boolean <optional>
!!CB_Configuration[CB_BASE_NAME].CB_AudioDetector_allowEmulation_DEFAULT

If set to true, it will also detect as supported emulated audio APIs (as "WAAPI" using waapisim.js instead of supported natively).

returnOnEmpty boolean <optional>

If set to true and no audio API is supported, it will return the value of this parameter instead of null.

Source:
Returns:

Returns a string with the preferred audio API (from an array if it is given) for the current client, if any. If no audio API is supported, it will return the value set in the "returnOnEmpty" parameter.

Type
string | *

<static> getSupportedAPIs( [audioAPIs] [, allowEmulation]) → {array}

Calculates and returns an array with the audio APIs supported (from an array if it is given) for the current client, if any.

Parameters:
Name Type Argument Default Description
audioAPIs array <optional>
CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS

An array of strings with the audio APIs that we want to check. All existing ones are defined in CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API).

allowEmulation boolean <optional>
!!CB_Configuration[CB_BASE_NAME].CB_AudioDetector_allowEmulation_DEFAULT

If set to true, it will also detect as supported emulated audio APIs (as "WAAPI" using waapisim.js instead of supported natively).

Source:
Returns:

Returns an array with the audio APIs supported (from an array if it is given) for the current client, if any. If no audio API is supported, an empty array will be returned.

Type
array

<static> getSupportedAudioFormats( [audioFormats] [, supportLevels] [, dataURI]) → {array}

Returns an array of strings with the audio formats that are supported (from an array if it is given) by the current client and ordered by support level. Uses the CB_AudioDetector.isAudioFormatSupported function internally.

Parameters:
Name Type Argument Default Description
audioFormats array <optional>
CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_FORMATS

An array of strings with the audio format or audio formats (they can include just the format as 'audio/ogg' or also the codec as for example 'audio/ogg; codecs="vorbis"') that we want to check.

supportLevels array <optional>
['probably', 'maybe']

An array with the support level or support levels allowed. Two possible levels: "probably" and "maybe". The "probably" audio formats are more likely to be supported than the "maybe" ones.

dataURI boolean <optional>
false

Specifies whether we want to check the support for data URI audios or just for normal audio files.

Source:
Returns:

Returns an array of strings with the audio formats that are supported (from an array if it is given) and ordered by support level.

Type
array

<static> isAPISupported(audioAPI [, allowEmulation]) → {boolean}

Tells whether a given audio API is supported or not by the current client.

Parameters:
Name Type Argument Default Description
audioAPI string

The audio API that we want to check. All existing ones are defined in CB_Configuration.CrossBase.CB_AudioFileCache_PREFERRED_AUDIO_APIS. For example: "WAAPI" (HTML5 Web Audio API), "SM2" (SoundManager 2), "ACMP" (Apache Cordova Media Plugin) or "AAPI" (HTML5 Audio API).

allowEmulation boolean <optional>
!!CB_Configuration[CB_BASE_NAME].CB_AudioDetector_allowEmulation_DEFAULT

If set to true, it will detect as supported also emulated audio APIs (as "WAAPI" using waapisim.js instead of supported natively).

Source:
To Do:
  • Have into account allowEmulation and detect whether emulation is being used if so (for example, detect whether waapisim.js is being used).
Returns:

Returns whether the given audio API is supported or not.

Type
boolean

<static> isAudioFormatSupported(audioFormat [, dataURI]) → {string}

Returns the support level of a given audio format by the current client.

Parameters:
Name Type Argument Default Description
audioFormat string

The audio format (it can include just the format as 'audio/ogg' or also the codec as for example 'audio/ogg; codecs="vorbis"') that we want to check.

dataURI boolean <optional>
false

Specifies whether we want to check the support for data URI audios or just for normal audio files.

Source:
To Do:
  • Think about using MediaSource.isTypeSupported().
  • Some web clients does not support data URIs for Audio element so we should take this into account.
  • Take into account that data URIs may not be supported when WAAPI is being emulated.
Returns:

Returns the support level of the given audio format (it will return "probably", "maybe" or an empty string which means not supported). The "probably" audio formats are more likely to be supported than the "maybe" ones.

Type
string

<static> isSM2UsingFlash() → {boolean}

Tells whether SoundManager 2 is using Adobe Flash (formerly Macromedia Flash) to emulate sound or not.

Source:
Returns:

Returns whether SoundManager 2 is using Adobe Flash (formerly Macromedia Flash) to emulate sound or not.

Type
boolean

<static> isWAAPIUsingEmulation() → {boolean}

Tells whether "WAAPI" (HTML5 Web Audio API) is using emulation (through WAAPISim) or not.

Source:
Returns:

Returns whether "WAAPI" (HTML5 Web Audio API) is using emulation (through WAAPISim) or not.

Type
boolean