To use Samsung Product API,
<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>
Should be loaded in index.html
Since : 2.3
Product : TV
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Interface | Method |
---|---|
MicrophoneManagerObject | |
MicrophoneManager | DOMString getVersion (); boolean isConnected (DOMString uid); void getMicrophones (MicrophoneDeviceArraySuccessCallback onsuccess, optional ErrorCallback ? onerror); unsigned long addMicrophoneConnectListener (MicrophoneConnectCallback listener); void removeMicrophoneConnectListener (unsigned long listenerId); |
MicrophoneDeviceArraySuccessCallback | void onsuccess (MicrophoneDevice[] devices); |
MicrophoneConnectCallback | void onevent(MicrophoneConnectEvent event) ; |
MicrophoneConnectEvent | |
MicrophoneConnectEventType | |
MicrophoneSampleRateValue | |
MicrophoneDeviceAudioFormat | |
MicrophoneEffectValue | |
MicrophoneStateValue | |
MicrophoneAudioinputEvent | |
MicrophoneDevice | DOMString getUniqueId (); unsigned long getDeviceId() ; DOMString getName (); boolean enableDevice (unsigned long format, unsigned long sampleRate); boolean disableDevice (); boolean stop (optional unsigned long ? state); boolean play (optional boolean ? lockState); unsigned long getVolumeLevel(); boolean setVolumeLevel (unsigned long volume); unsigned long getSupportedEffect (); unsigned long getEnabledEffect (); boolean setEffect (unsigned long 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); |
MicrophoneEventCallback | void onevent (unsigned long eventType); |
[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);
};
getVersion
DOMString getVersion();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Plugin versionExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
try {
var value = webapis.microphone.getVersion();
console.log(" version value = " + value);
} catch (error) {
console.log(" error code = " + error.code);
}
isConnected
boolean isConnected(DOMString uid);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
Boolean value:Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
try {
var flag = webapis.microphone.isConnected(uid);
console.log(" microphone connected = " + flag);
} catch (error) {
console.log(" error code = " + error.code);
}
getMicrophones
void getMicrophones(MicrophoneDeviceArraySuccessCallback onsuccess, optional ErrorCallback ? onerror);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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);
}
addMicrophoneConnectListener
unsigned long addMicrophoneConnectListener(MicrophoneConnectCallback listener);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
MicrophoneConnectCallback IDExceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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);
}
removeMicrophoneConnectListener
void removeMicrophoneConnectListener(unsigned long listenerId);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
try { webapis.microphone.removeMicrophoneConnectListener(listenerId);
console.log("listener id = " + value);
} catch (error) {
console.log(" error code = " + error.code);
}
[Callback = FunctionOnly, NoInterfaceObject]interface MicrophoneDeviceArraySuccessCallback {
void onsuccess(MicrophoneDevice[] devices);
};
onsuccess
void onsuccess(MicrophoneDevice[] devices);
Parameters:
Code example:
function onsuccess(devices) {
for (var i in devices)
{
console.log("SystemConfig devices = " + devices[i]);
}
}
[Callback = FunctionOnly, NoInterfaceObject]interface MicrophoneConnectCallback {
void onevent(MicrophoneConnectEvent event);
};
onsuccess
void onevent(MicrophoneConnectEvent event);
Parameters:
Code example:
var onevent = function (event){
console.log("changing event is = " + event);
}
[NoInterfaceObject]interface MicrophoneConnectEvent {
readonly attribute DOMString uid;
readonly attribute DOMString name;
readonly 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 {
readonly attribute DOMString uid;
readonly attribute DOMString name;
readonly attribute long deviceId;
readonly attribute long deviceType;
DOMString getUniqueId();
unsigned long getDeviceId();
DOMString getName();
boolean enableDevice(unsigned long format, unsigned long sampleRate);
boolean disableDevice();
boolean stop(optional unsigned long ? state);
boolean play(optional boolean ? lockState);
unsigned long getVolumeLevel();
boolean setVolumeLevel(unsigned long volume);
unsigned long getSupportedEffect();
unsigned long getEnabledEffect();
boolean setEffect(unsigned long 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);
};
getUniqueId
DOMString getUniqueId();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Device UIDCode example:
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);
}
}
});
getDeviceId
unsigned long getDeviceId();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Device IDCode example:
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);
}
}
});
getName
DOMString getName();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Device nameCode example:
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);
}
}
});
enableDevice
boolean enableDevice(MicrophoneDeviceAudioFormat format, MicrophoneSampleRateValue sampleRate);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
Boolean value:Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
disableDevice
boolean disableDevice();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Boolean value:Code example:
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);
}
}
});
stop
boolean stop(optional MicrophoneStateValue ? state);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
Boolean value:Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
play
boolean play(optional boolean ? lockState);
Since : 2.3
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
Boolean value:Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
getVolumeLevel
unsigned long getVolumeLevel();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
volume levelCode example:
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);
}
}
});
setVolumeLevel
boolean setVolumeLevel(unsigned long volume);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
Boolean value:Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
getSupportedEffect
MicrophoneEffectValue getSupportedEffect();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Microphone effectCode example:
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);
}
}
});
getEnabledEffect
MicrophoneEffectValue getEnabledEffect();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Microphone effectCode example:
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);
}
}
});
setEffect
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);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
Boolean value:Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
getFilterVolume
unsigned long getFilterVolume();
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Return value:
Filter volumeCode example:
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);
}
}
});
addMicrophoneEventListener
unsigned long addMicrophoneEventListener(MicrophoneEventCallback listener);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Return value:
MicrophoneEventCallback IDExceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
removeMicrophoneEventListener
void removeMicrophoneEventListener(unsigned long listenerId);
Privilege level: public
Privilege: http://developer.samsung.com/privilege/microphone
Parameters:
Exceptions:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
}
}
});
[Callback = FunctionOnly, NoInterfaceObject]interface MicrophoneEventCallback {
void onevent(unsigned long eventType);
};
Since : 2.3
onevent
void onevent(MicrophoneConnectEventType eventType);
Parameters:
Code example:
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 {
readonly attribute DOMString uid;
readonly attribute DOMString name;
readonly 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 {
readonly attribute DOMString uid;
readonly attribute DOMString name;
readonly attribute long deviceId;
readonly 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);
};
};