Camera

Service URI - luna://com.webos.service.camera

Provides methods that return the information of a camera and microphone.

The Camera Service manages camera/microphone devices that are connected to webOS TV. You can get device URI with this API and get more information on each device with device URI.

Caution: API Deprecation
This API is deprecated from webOS TV 4.0.

Methods

MethodDescriptionSupported in Emulator
getInfoReturns the detailed information of a device.No
getListReturns a list of camera and microphone devices which are connected to webOS TV.No
isCoveredReturns the cover status of the built-in camera.No

getInfo

Description

Returns the detailed information of a device. You need to put URI as a parameter which is given by getList() method.

Parameters

NameRequiredTypeDescription
uriRequiredstringDevice URI

Call returns

NameRequiredTypeDescription
returnValueRequiredbooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalnumbererrorCode contains the error code if the method fails. The method will return errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalstringerrorText contains the error text if the method fails. The method will return errorText only if it fails.
See the Error Codes Reference of this method for more details.
infoOptionalobjectObject that holds the detailed information of a device.

Error reference

Error CodeError Message
1Can not close
2Can not open
3Can not set
4Can not start
5Can not stop
6The camera device is already closed
7The camera device is already opened
8The camera device is already started
9The camera device is already stopped
10The camera device is being updated
11The camera device is busy
12The camera device is not opened
13The camera device is not started
14There is no device
15No response from the device
16Parsing error
17Out of memory
18Out of parameter range
19Parameter is missing
20Service is not ready
21Some parameters are not set
22Too many requests
23Request timeout
24Unknown service
25Unsupported device
26Unsupported format
27Unsupported sampling rate
28Unsupported video size
29Camera firmware is being updated
30Wrong device number
31Session ID error
32Wrong parameter
33Wrong type
34Already acquired
35Unknown error
36Fail to Special effect
37Fail to photo view effect
38Fail to open file
39Fail to remove the file
40Fail to create the directory
41Lack of storage
42Already exists file

Example

// Example for camera device
var request = webOS.service.request('luna://com.webos.service.camera', {
  method: 'getInfo',
  parameters: { uri: 'camera://com.webos.service.camera/camera1' },
  onSuccess: function (inResponse) {
    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get camera device info');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

// Example for microphone device
var request = webOS.service.request('luna://com.webos.service.camera', {
  method: 'getInfo',
  parameters: { uri: 'camera://com.webos.service.camera/mic1' },
  onSuccess: function (inResponse) {
    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get microphone device info');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

Return example

// Camera device information
{
  'returnValue': true,
  'info': {
      'name': 'BC600 Camera',
      'type': 'camera',
      'builtin': true,
      'details': {
          'video': {
              'maxWidth': 1920,
              'maxHeight': 1080
          },
          'picture': {
              'maxWidth': 3264,
              'maxHeight': 2448
          },
          'format': 'H264ES|H264TS|SECS|MP4|'
      }
  }
}

// Microphone device information
{
  'returnValue': true,
  'info': {
      'name': 'BC600 Camera',
      'type': 'microphone',
      'builtin': true,
      'details': {
          'samplingRate': 'WB',
          'codec': 'PCM'
      }
  }
}

// Failure return
{
  'returnValue': false,
  'errorCode': '32',
  'errorText': 'Wrong param'
}

See also

getList

Description

Returns a list of camera and microphone devices which are connected to webOS TV.

This method provides a subscription. Whenever a device is connected or disconnected, the event occurs. The updated list will be returned for every event.

Parameters

NameRequiredTypeDescription
subscribeOptionalbooleanFlag that decides whether to subscribe or not.
  • true: Subscribe.
  • false: Do not subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValueRequiredbooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalnumbererrorCode contains the error code if the method fails. The method will return errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalstringerrorText contains the error text if the method fails. The method will return errorText only if it fails.
See the Error Codes Reference of this method for more details.
uriListOptionalobject arrayList of devices which are connected to webOS TV. This object holds device type and URI. If there is no connected device, getLIst() will return an empty array.
subscribedOptionalbooleanFlag that indicates whether the subscription is enabled or not.
  • true: Enabled
  • false: Not enabled.

Error reference

Error CodeError Message
1Can not close
2Can not open
3Can not set
4Can not start
5Can not stop
6Camera device is already closed
7Camera device is already opened
8Camera device is already started
9Camera device is already stopped
10Camera device is being updated
11Camera device is busy
12Camera device is not opened
13Camera device is not started
14There is no device
15No response from device
16Parsing error
17Out of memory
18Out of parameter range
19Parameter is missing
20Service is not ready
21Some parameters are not set
22Too many requests
23Request timeout
24Unknown service
25Unsupported device
26Unsupported format
27Unsupported sampling rate
28Unsupported video size
29Camera firmware is being updated
30Wrong device number
31Session ID error
32Wrong parameter
33Wrong type
34Already acquired
35Unknown error
36Fail to Special effect
37Fail to photo view effect
38Fail to open file
39Fail to remove file
40Fail to create directory
41Lack of storage
42Already exists file

Subscription Returns

NameRequiredTypeDescription
uriListRequiredObject arrayList of devices which are connected to webOS TV. this object holds device type and URI, If there is no connected device, getList() will return empty array.

Example

// One-time call
var request = webOS.service.request('luna://com.webos.service.camera', {
  method: 'getList',
  onSuccess: function (inResponse) {
    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get camera device list');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

// Subscription
var subscriptionHandle;

subscriptionHandle = webOS.service.request('luna://com.webos.service.camera', {
  method: 'getList',
  parameters: { subscribe: true },
  onSuccess: function (inResponse) {
    if (typeof inResponse.subscribed != 'undefined') {
      if (!inResponse.subscribed) {
        console.log('Failed to subscribe the camera device list');
        return;
      }
    }

    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get camera device list');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});
...
// If you need to unsubscribe the data, use cancel() method as below
subscriptionHandle.cancel();

Return example

// One-time call return
{
  'returnValue': true,
  'uriList': [
      {
          'uri': 'camera://com.webos.service.camera/camera1',
          'type': 'camera'
      },
      {
          'uri': 'camera://com.webos.service.camera/mic1',
          'type': 'microphone'
      }
  ]
}

// No device connected
{
  'returnValue': true,
  'uriList': [ ],
  'subscribed': true
}

// Failure return
{
  'returnValue': false,
  'errorCode': '23',
  'errorText': 'Request timeout'
}

// When using subscription return
{
  'returnValue': true,
  'uriList': [
      {
          'uri': 'camera://com.webos.service.camera/camera1',
          'type': 'camera'
      },
      {
          'uri': 'camera://com.webos.service.camera/mic1',
          'type': 'microphone'
      }
  ],
  'subscribed': true
}

// Subscription return
{
  'uriList': [
      {
          'uri': 'camera://com.webos.service.camera/camera1',
          'type': 'camera'
      },
      {
          'uri': 'camera://com.webos.service.camera/mic1',
          'type': 'microphone'
      }
  ]
}

// No device connected (Subscription return)
{
  'uriList': [ ]
}

See also

isCovered

Description

Returns the cover status of the built-in camera. You need to put URI as a parameter which is given by getList().

Parameters

NameRequiredTypeDescription
uriRequiredstringDevice URI
subscribeOptionalbooleanFlag that decides whether to subscribe or not.
  • true: Subscribe.
  • false: Do not subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValueRequiredbooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalnumbererrorCode contains the error code if the method fails. The method will return errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalstringerrorText contains the error text if the method fails. The method will return errorText only if it fails.
See the Error Codes Reference of this method for more details.
coveredOptionalbooleanFlag that indicates whether the built-in camera is covered or not.
  • true: Covered
  • false: Not covered
subscribedOptionalbooleanFlag that indicates whether the subscription is enabled or not.
  • true: Enabled
  • false: Not enabled.

Error reference

Error CodeError Message
1Can not close
2Can not open
3Can not set
4Can not start
5Can not stop
6Camera device is already closed
7Camera device is already opened
8Camera device is already started
9Camera device is already stopped
10Camera device is being updated
11Camera device is busy
12Camera device is not opened
13Camera device is not started
14There is no device
15No response from device
16Parsing error
17Out of memory
18Out of parameter range
19Parameter is missing
20Service is not ready
21Some parameters are not set
22Too many requests
23Request timeout
24Unknown service
25Unsupported device
26Unsupported format
27Unsupported sampling rate
28Unsupported video size
29Camera firmware is being updated
30Wrong device number
31Session ID error
32Wrong parameter
33Wrong type
34Already acquired
35Unknown error
36Fail to Special effect
37Fail to photo view effect
38Fail to open file
39Fail to remove file
40Fail to create directory
41Lack of storage
42Already exists file

Subscription Returns

NameRequiredTypeDescription
coveredRequiredBooleanFlag that indicates whether the built-in camera is covered or not.
  • true: Covered
  • false: Not covered

Example

// One-time call
var request = webOS.service.request('luna://com.webos.service.camera', {
  method: 'isCovered',
  parameters: { id: 'camera://com.webos.service.camera/camera1' },
  onSuccess: function (inResponse) {
    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get camera cover state');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

// Subscription
var subscriptionHandle;

subscriptionHandle = webOS.service.request('luna://com.webos.service.camera', {
  method: 'isCovered',
  parameters: {
    id: 'camera://com.webos.service.camera/camera1',
    subscribe: true,
  },
  onSuccess: function (inResponse) {
    if (typeof inResponse.subscribed != 'undefined') {
      if (!inResponse.subscribed) {
        console.log('Failed to subscribe the camera cover state');
        return;
      }
    }
    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get camera cover state');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});
...
// If you need to unsubscribe the data, use cancel() method as below
subscriptionHandle.cancel();

Return example

// One-time call return
{
  'returnValue': true,
  'covered': true
}

// Subscription return
{
  'returnValue': false,
  'covered': false,
  'subscribed': true
}

See also

Object

deviceInfo object

The object that holds the detailed information of camera or microphone devices.

{
  'name': string,
  'type': string,
  'builtin': boolean,
  'details': deviceDetail object
} 
NameRequiredTypeDescription
nameRequiredstringDevice name
typeRequiredstringDevice type (camera or microphone)
builtinRequiredbooleanFlag that indicates whether the device is built in or not.
detailsRequiredobjectObject that holds information about recording resolution, supported video format, sampling rate, and audio code.

uriList object

List of devices which are connected to webOS TV. This object holds device type and URI.

{
    'uri': string,
    'type': string
}
NameRequiredTypeDescription
uriRequiredstringURI of device
typeRequiredstringType of device that distinguishes between camera and microphone.

deviceDetail object

The object that holds more detailed information for a camera and microphone.

{
  'video': videoDetail Object,
  'picture': pictureDetail Object,
  'format': String,
  'samplingRate': String,
  'codec': String
} 
NameRequiredTypeDescription
videoOptionalobjectObject that holds a supported maximum video frame size for video recording.
pictureOptionalobjectObject that holds a supported maximum image size for picture taking.
formatOptionalstringSupported Video format for video recording. In return string, pipe character (|) is used as a delimiter to distinguish multi-formats.
samplingRateOptionalstringSupported sampling rate for audio recording.
codecOptionalstringSupported audio codec for audio recording.

videoDetail object

The object that holds a supported maximum video frame size for video recording. This object has maximum width and height.

{
  'maxWidth': Number,
  'maxHeight': Number
} 
NameRequiredTypeDescription
maxWidthRequirednumberMaximum width that camera device supports for video recording
maxHeightRequirednumberMaximum height that camera device supports for video recording.

pictureDetail object

The object that holds a supported maximum image size for picture taking. This object has maximum width and height.

{
  'maxWidth': Number,
  'maxHeight': Number
} 
NameRequiredTypeDescription
maxWidthRequirednumberMaximum width that camera device supports for picture taking
maxHeightRequirednumberMaximum height that camera device supports for picture taking
No Headings