To use Samsung Product API, <script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script> Should be loaded in index.html
To use Samsung Product API,
<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>
Should be loaded in index.html
This module defines the microphone functionalities provided by the Tizen Samsung Product API.
Since : 2.3
Product : TV, B2B
Privilege Level : Public
Privilege : http://developer.samsung.com/privilege/microphone
Defines a WebApi object instance of the Tizen Samsung Product API. The webapis.microphone object enables access to Microphone API functionality.
[NoInterfaceObject] interface MicrophoneManagerObject { readonly attribute MicrophoneManager microphone; };
WebApi implements MicrophoneManagerObject;
Provides methods for microphone functionalities.
[NoInterfaceObject] interface MicrophoneManager { DOMString getVersion(); boolean isConnected(DOMString uid); void getMicrophones(MicrophoneDeviceArraySuccessCallback onsuccess, optional ErrorCallback? onerror); unsigned long addMicrophoneConnectListener(MicrophoneConnectCallback listener); void removeMicrophoneConnectListener(unsigned long listenerId); };
Retrieves the plugin version number.
DOMString getVersion();
Return Value :
Exceptions :
Code Example :
try { var value = webapis.microphone.getVersion(); console.log(" version value = " + value); } catch (error) { console.log(" error code = " + error.code); }
Checks whether a microphone is connected.
boolean isConnected(DOMString uid);
Parameters :
try { var flag = webapis.microphone.isConnected(uid); console.log(" microphone connected = " + flag); } catch (error) { console.log(" error code = " + error.code); }
Retrieves a list of all connected microphones.
void getMicrophones(MicrophoneDeviceArraySuccessCallback onsuccess, optional ErrorCallback? onerror);
function onsuccess(mics) { if(mics && mics.length > 0){ for(var i = 0; i < mics.length; i++){ if(mics[i]!=null){ console.log( i + " " + mics[i]); } } }else{ console.log("No microphone found. Check that a microphone is connected, and try again in a few seconds."); } } try { webapis.microphone.getMicrophones(onsuccess); } catch (error) { console.log(" error code = " + error.code); }
Registers a microphone connection listener.
unsigned long addMicrophoneConnectListener(MicrophoneConnectCallback listener);
var callback = function(deviceInfo) { console.log("device name is " + deviceInfo.name); console.log("device uid is " + deviceInfo.uid); console.log("device eventType is " + deviceInfo.eventType); } try { var listenerId = webapis.microphone.addMicrophoneConnectListener(callback); console.log("listener id = " + listenerId); } catch (error) { console.log(" error code = " + error.code); }
Unregisters a microphone connection listener registered by addMicrophoneConnectListener.
void removeMicrophoneConnectListener(unsigned long listenerId);
try { webapis.microphone.removeMicrophoneConnectListener(listenerId); console.log("listener id = " + value); } catch (error) { console.log(" error code = " + error.code); }
Defines the device list callback.
[Callback = FunctionOnly, NoInterfaceObject] interface MicrophoneDeviceArraySuccessCallback { void onsuccess(MicrophoneDevice[] devices); };
Callback method returning the device list.
void onsuccess(MicrophoneDevice[] devices);
function onsuccess(devices) { for (var i in devices) { console.log("SystemConfig devices = " + devices[i]); } }
Defines the microphone connection listener.
[Callback = FunctionOnly, NoInterfaceObject] interface MicrophoneConnectCallback { void onevent(MicrophoneConnectEvent event); };
Callback method for microphone connection notifications.
void onevent(MicrophoneConnectEvent event);
var onevent = function (event){ console.log("changing event is = " + event); }
Defines microphone connection event structure.
[NoInterfaceObject] interface MicrophoneConnectEvent { attribute DOMString uid; attribute DOMString name; attribute unsigned long eventType; };
Defines microphone connection event type.
[NoInterfaceObject] interface MicrophoneConnectEventType { const unsigned long EVENT_DEVICE_CONNECT = 11; const unsigned long EVENT_DEVICE_DISCONNECT = 12; };
Defines constants for sample rates.
[NoInterfaceObject] interface MicrophoneSampleRateValue { const unsigned long MICROPHONE_SAMPLE_RATE_48000 = 48000; const unsigned long MICROPHONE_SAMPLE_RATE_44100 = 44100; const unsigned long MICROPHONE_SAMPLE_RATE_32000 = 32000; const unsigned long MICROPHONE_SAMPLE_RATE_16000 = 16000; const unsigned long MICROPHONE_SAMPLE_RATE_8000 = 8000; };
Defines constants for microphone device formats.
[NoInterfaceObject] interface MicrophoneDeviceAudioFormat { const unsigned long MICROPHONE_FORMAT_SIGNED_16BIT_LITTLE_ENDIAN = 0; const unsigned long MICROPHONE_FORMAT_SIGNED_16BIT_BIG_ENDIAN_FORMAT = 1; };
Defines constants for microphone effects.
[NoInterfaceObject] interface MicrophoneEffectValue { const unsigned long MICROPHONE_EFFECT_NONE = 0x00; const unsigned long MICROPHONE_EFFECT_REVERB = 0x01; const unsigned long MICROPHONE_EFFECT_FILTER = 0x10; };
Defines constants for microphone states.
[NoInterfaceObject] interface MicrophoneStateValue { const unsigned long MICROPHONE_STATUS_STOP = 0x00000000; const unsigned long MICROPHONE_STATUS_PLAY = 0x00000001; const unsigned long MICROPHONE_STATUS_RECORD = 0x00000010; const unsigned long MICROPHONE_STATUS_FILTER = 0x00000100; };
Defines constants for microphone input events.
[NoInterfaceObject] interface MicrophoneAudioinputEvent { const unsigned long MICROPHONE_AUDIOINPUT_PLAY_FAIL = 400; const unsigned long MICROPHONE_AUDIOINPUT_DATA = 401; const unsigned long MICROPHONE_AUDIOINPUT_RECORD_FAIL = 402; const unsigned long MICROPHONE_AUDIOINPUT_RECORD_STOP = 403; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_VOICE_DETECTED = 404; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_PLAY_START = 405; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_PLAY_STOP = 406; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_SILENCE_DETECTED = 407; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_PLAY_VOLUME = 450; };
Provides methods for microphone device functionalities.
[NoInterfaceObject] interface MicrophoneDevice { attribute DOMString uid; attribute DOMString name; attribute long deviceId; attribute long deviceType; DOMString getUniqueId(); unsigned long getDeviceId(); DOMString getName(); boolean enableDevice(MicrophoneDeviceAudioFormat format, MicrophoneSampleRateValue sampleRate); boolean disableDevice(); boolean stop(optional MicrophoneStateValue? state); boolean play(optional boolean? lockState); unsigned long getVolumeLevel(); boolean setVolumeLevel(unsigned long volume); MicrophoneEffectValue getSupportedEffect(); MicrophoneEffectValue getEnabledEffect(); boolean setEffect(MicrophoneEffectValue effect, boolean enable, optional unsigned long? tempo, optional unsigned long? pitch, optional unsigned long? rate, optional unsigned long? threshold, optional unsigned long? noduration); unsigned long getFilterVolume(); unsigned long addMicrophoneEventListener(MicrophoneEventCallback listener); void removeMicrophoneEventListener(unsigned long listenerId); };
Retrieves the unique ID.
DOMString getUniqueId();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.getUniqueId(); } catch (error) { console.log(" error code = " + error.code); } } });
Retrieves the device ID.
unsigned long getDeviceId();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.getDeviceId(); } catch (error) { console.log(" error code = " + error.code); } } });
Retrieves the device name.
DOMString getName();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.getName(); } catch (error) { console.log(" error code = " + error.code); } } });
Enables the microphone device.
boolean enableDevice(MicrophoneDeviceAudioFormat format, MicrophoneSampleRateValue sampleRate);
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.enableDevice(webapis.microphone.MICROPHONE_FORMAT_SIGNED_16BIT_LITTLE_ENDIAN,webapis.microphone.MICROPHONE_SAMPLE_RATE_48000); } catch (error) { console.log(" error code = " + error.code); } } });
Disables a microphone device.
boolean disableDevice();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.disableDevice(); } catch (error) { console.log(" error code = " + error.code); } } });
Stops the microphone.
boolean stop(optional MicrophoneStateValue? state);
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.stop(webapis.microphone.MICROPHONE_STATUS_PLAY | webapis.microphone.MICROPHONE_STATUS_RECORD); } catch (error) { console.log(" error code = " + error.code); } } });
Plays the microphone.
boolean play(optional boolean? lockState);
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.play(); } catch (error) { console.log(" error code = " + error.code); } } });
Retrieves the volume level.
unsigned long getVolumeLevel();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.getVolumeLevel(); } catch (error) { console.log(" error code = " + error.code); } } });
Sets the volume level.
boolean setVolumeLevel(unsigned long volume);
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var volume = 50; var value = device.setVolumeLevel(volume); } catch (error) { console.log(" error code = " + error.code); } } });
Retrieves the supported effects.
MicrophoneEffectValue getSupportedEffect();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var effects = device.getSupportedEffect(); if(effects == webapis.microphone.MICROPHONE_EFFECT_NONE) { console.log("No effects supported"); } else { if(effects & webapis.microphone.MICROPHONE_EFFECT_REVERB) { console.log("REVERB effect supported"); } if(effects & webapis.microphone.MICROPHONE_EFFECT_FILTER) { console.log("FILTER effect supported"); } } } catch (error) { console.log("error code = " + error.code); } } });
Retrieves the enabled effects.
MicrophoneEffectValue getEnabledEffect();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var effects = device.getEnabledEffect(); if(effects == webapis.microphone.MICROPHONE_EFFECT_NONE) { console.log("No effects enabled"); } else { if(effects & webapis.microphone.MICROPHONE_EFFECT_REVERB) { console.log("REVERB effect enabled"); } if(effects & webapis.microphone.MICROPHONE_EFFECT_FILTER) { console.log("FILTER effect enabled"); } } } catch (error) { console.log("error code = " + error.code); } } });
Sets a microphone effect.
boolean setEffect(MicrophoneEffectValue effect, boolean enable, optional unsigned long? tempo, optional unsigned long? pitch, optional unsigned long? rate, optional unsigned long? threshold, optional unsigned long? noduration);
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var flag = device.setEffect(webapis.microphone.MICROPHONE_EFFECT_FILTER, true, Number(tempo), Number(pitch), Number(rate), Number(threshold), Number(noduration)); } catch (error) { console.log(" error code = " + error.code); } } });
Retrieves the filter volume.
unsigned long getFilterVolume();
webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var value = device.getFilterVolume(); } catch (error) { console.log(" error code = " + error.code); } } });
Registers a microphone event listener.
unsigned long addMicrophoneEventListener(MicrophoneEventCallback listener);
var onevent = function(eventType) { console.log("eventType is " + eventType); } webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var listenerId = device.addMicrophoneEventListener(onevent); console.log("listener id = " + listenerId); } catch (error) { console.log(" error code = " + error.code); } } });
Unregisters a microphone event listener registered by addMicrophoneEventListener.
void removeMicrophoneEventListener(unsigned long listenerId);
var onevent = function(eventType) { console.log("eventType is " + eventType); } webapis.microphone.getMicrophones(function(mics){ if (mics && mics.length > 0) { var device = mics[0]; try { var listenerId = device.addMicrophoneEventListener(onevent); device.removeMicrophoneEventListener(listenerId); } catch (error) { console.log(" error code = " + error.code); } } });
Defines a listener for device events.
[Callback = FunctionOnly, NoInterfaceObject] interface MicrophoneEventCallback { void onevent(MicrophoneConnectEventType eventType); };
Callback method for microphone event notifications.
void onevent(MicrophoneConnectEventType eventType);
var onevent = function (eventType){ console.log(" onevent eventType is = " + eventType); }
module Microphone { [NoInterfaceObject] interface MicrophoneManagerObject { readonly attribute MicrophoneManager microphone; }; WebApi implements MicrophoneManagerObject; [NoInterfaceObject] interface MicrophoneManager { DOMString getVersion(); boolean isConnected(DOMString uid); void getMicrophones(MicrophoneDeviceArraySuccessCallback onsuccess, optional ErrorCallback? onerror); unsigned long addMicrophoneConnectListener(MicrophoneConnectCallback listener); void removeMicrophoneConnectListener(unsigned long listenerId); }; [Callback = FunctionOnly, NoInterfaceObject] interface MicrophoneDeviceArraySuccessCallback { void onsuccess(MicrophoneDevice[] devices); }; [Callback = FunctionOnly, NoInterfaceObject] interface MicrophoneConnectCallback { void onevent(MicrophoneConnectEvent event); }; [NoInterfaceObject] interface MicrophoneConnectEvent { attribute DOMString uid; attribute DOMString name; attribute unsigned long eventType; }; [NoInterfaceObject] interface MicrophoneConnectEventType { const unsigned long EVENT_DEVICE_CONNECT = 11; const unsigned long EVENT_DEVICE_DISCONNECT = 12; }; [NoInterfaceObject] interface MicrophoneSampleRateValue { const unsigned long MICROPHONE_SAMPLE_RATE_48000 = 48000; const unsigned long MICROPHONE_SAMPLE_RATE_44100 = 44100; const unsigned long MICROPHONE_SAMPLE_RATE_32000 = 32000; const unsigned long MICROPHONE_SAMPLE_RATE_16000 = 16000; const unsigned long MICROPHONE_SAMPLE_RATE_8000 = 8000; }; [NoInterfaceObject] interface MicrophoneDeviceAudioFormat { const unsigned long MICROPHONE_FORMAT_SIGNED_16BIT_LITTLE_ENDIAN = 0; const unsigned long MICROPHONE_FORMAT_SIGNED_16BIT_BIG_ENDIAN_FORMAT = 1; }; [NoInterfaceObject] interface MicrophoneEffectValue { const unsigned long MICROPHONE_EFFECT_NONE = 0x00; const unsigned long MICROPHONE_EFFECT_REVERB = 0x01; const unsigned long MICROPHONE_EFFECT_FILTER = 0x10; }; [NoInterfaceObject] interface MicrophoneStateValue { const unsigned long MICROPHONE_STATUS_STOP = 0x00000000; const unsigned long MICROPHONE_STATUS_PLAY = 0x00000001; const unsigned long MICROPHONE_STATUS_RECORD = 0x00000010; const unsigned long MICROPHONE_STATUS_FILTER = 0x00000100; }; [NoInterfaceObject] interface MicrophoneAudioinputEvent { const unsigned long MICROPHONE_AUDIOINPUT_PLAY_FAIL = 400; const unsigned long MICROPHONE_AUDIOINPUT_DATA = 401; const unsigned long MICROPHONE_AUDIOINPUT_RECORD_FAIL = 402; const unsigned long MICROPHONE_AUDIOINPUT_RECORD_STOP = 403; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_VOICE_DETECTED = 404; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_PLAY_START = 405; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_PLAY_STOP = 406; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_SILENCE_DETECTED = 407; const unsigned long MICROPHONE_AUDIOINPUT_FILTER_PLAY_VOLUME = 450; }; [NoInterfaceObject] interface MicrophoneDevice { attribute DOMString uid; attribute DOMString name; attribute long deviceId; attribute long deviceType; DOMString getUniqueId(); unsigned long getDeviceId(); DOMString getName(); boolean enableDevice(MicrophoneDeviceAudioFormat format, MicrophoneSampleRateValue sampleRate); boolean disableDevice(); boolean stop(optional MicrophoneStateValue? state); boolean play(optional boolean? lockState); unsigned long getVolumeLevel(); boolean setVolumeLevel(unsigned long volume); MicrophoneEffectValue getSupportedEffect(); MicrophoneEffectValue getEnabledEffect(); boolean setEffect(MicrophoneEffectValue effect, boolean enable, optional unsigned long? tempo, optional unsigned long? pitch, optional unsigned long? rate, optional unsigned long? threshold, optional unsigned long? noduration); unsigned long getFilterVolume(); unsigned long addMicrophoneEventListener(MicrophoneEventCallback listener); void removeMicrophoneEventListener(unsigned long listenerId); }; [Callback = FunctionOnly, NoInterfaceObject] interface MicrophoneEventCallback { void onevent(MicrophoneConnectEventType eventType); }; };