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

Method

Description

Supported in Emulator

getInfo

Returns the detailed information of a device.

No

getList

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

No

isCovered

Returns 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

Name

Required

Type

Description

uri

Yes

String

Device URI

Call returns

NameRequiredTypeDescription
returnValue
Yes
Boolean
Flag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCode
No
Number
`errorCode` contains the error code if the method fails. The method will return `errorCode` only if it fails.
See the Error code reference of this method for more details.
errorText
No
String
`errorText` contains the error text if the method fails. The method will return `errorText` only if it fails.
See the Error code reference of this method for more details.
No
Object
Object that holds the detailed information of a device.

Error code reference

Error Code

Error Message

1

Can not close

2

Can not open

3

Can not set

4

Can not start

5

Can not stop

6

The camera device is already closed

7

The camera device is already opened

8

The camera device is already started

9

The camera device is already stopped

10

The camera device is being updated

11

The camera device is busy

12

The camera device is not opened

13

The camera device is not started

14

There is no device

15

No response from the device

16

Parsing error

17

Out of memory

18

Out of parameter range

19

Parameter is missing

20

Service is not ready

21

Some parameters are not set

22

Too many requests

23

Request timeout

24

Unknown service

25

Unsupported device

26

Unsupported format

27

Unsupported sampling rate

28

Unsupported video size

29

Camera firmware is being updated

30

Wrong device number

31

Session ID error

32

Wrong parameter

33

Wrong type

34

Already acquired

35

Unknown error

36

Fail to Special effect

37

Fail to photo view effect

38

Fail to open file

39

Fail to remove the file

40

Fail to create the directory

41

Lack of storage

42

Already 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
subscribe
No
Boolean
Flag that decides whether to subscribe or not.
  • true : Subscribe.
  • false : Do not subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValue
Yes
Boolean
Flag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCode
No
Number
`errorCode` contains the error code if the method fails. The method will return `errorCode` only if it fails.
See the Error code reference of this method for more details.
errorText
No
String
`errorText` contains the error text if the method fails. The method will return `errorText` only if it fails.
See the Error code reference of this method for more details.
No
Object array
List 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.
subscribed
No
Boolean
Flag that indicates whether the subscription is enabled or not.
  • true: Enabled
  • false: Not enabled

Error code reference

Error Code

Error Message

1

Can not close

2

Can not open

3

Can not set

4

Can not start

5

Can not stop

6

Camera device is already closed

7

Camera device is already opened

8

Camera device is already started

9

Camera device is already stopped

10

Camera device is being updated

11

Camera device is busy

12

Camera device is not opened

13

Camera device is not started

14

There is no device

15

No response from device

16

Parsing error

17

Out of memory

18

Out of parameter range

19

Parameter is missing

20

Service is not ready

21

Some parameters are not set

22

Too many requests

23

Request timeout

24

Unknown service

25

Unsupported device

26

Unsupported format

27

Unsupported sampling rate

28

Unsupported video size

29

Camera firmware is being updated

30

Wrong device number

31

Session ID error

32

Wrong parameter

33

Wrong type

34

Already acquired

35

Unknown error

36

Fail to Special effect

37

Fail to photo view effect

38

Fail to open file

39

Fail to remove file

40

Fail to create directory

41

Lack of storage

42

Already exists file

Subscription returns

NameRequiredTypeDescription
Yes
Object array
List 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.

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
uri
Yes
String
Device URI
subscribe
No
Boolean
Flag that decides whether to subscribe or not.
  • true : Subscribe.
  • false : Do not subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValue
Yes
Boolean
Flag that indicates success/failure of the request.
  • true : Success
  • false : Failure
errorCode
No
Number
`errorCode` contains the error code if the method fails. The method will return `errorCode` only if it fails.
See the Error code reference of this method for more details.
errorText
No
String
`errorText` contains the error text if the method fails. The method will return `errorText` only if it fails.
See the Error code reference of this method for more details.
covered
No
Boolean
Flag that indicates whether the built-in camera is covered or not.
  • true : Covered
  • false : Not covered
subscribed
No
Boolean
Flag that indicates whether the subscription is enabled or not.
  • true : Enabled
  • false : Not enabled

Error code reference

Error Code

Error Message

1

Can not close

2

Can not open

3

Can not set

4

Can not start

5

Can not stop

6

Camera device is already closed

7

Camera device is already opened

8

Camera device is already started

9

Camera device is already stopped

10

Camera device is being updated

11

Camera device is busy

12

Camera device is not opened

13

Camera device is not started

14

There is no device

15

No response from device

16

Parsing error

17

Out of memory

18

Out of parameter range

19

Parameter is missing

20

Service is not ready

21

Some parameters are not set

22

Too many requests

23

Request timeout

24

Unknown service

25

Unsupported device

26

Unsupported format

27

Unsupported sampling rate

28

Unsupported video size

29

Camera firmware is being updated

30

Wrong device number

31

Session ID error

32

Wrong parameter

33

Wrong type

34

Already acquired

35

Unknown error

36

Fail to Special effect

37

Fail to photo view effect

38

Fail to open file

39

Fail to remove file

40

Fail to create directory

41

Lack of storage

42

Already exists file

Subscription returns

NameRequiredTypeDescription
covered
Yes
Boolean
Flag 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
name
Yes
String
Device name
type
Yes
String
Device type (camera or microphone)
builtin
Yes
Boolean
Flag that indicates whether the device is built in or not.
Yes
Object
Object that holds information about recording resolution, supported video format, sampling rate, and audio codec.

uriList object

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

{
    "uri": string,
    "type": string
}

Name

Required

Type

Description

uri

Yes

String

URI of device

type

Yes

String

Type 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
No
Object
Object that holds a supported maximum video frame size for video recording.
No
Object
Object that holds a supported maximum image size for picture taking.
format
No
String
Supported video format for video recording. In return string, pipe character (|) is used as a delimiter to distinguish multi-formats.
samplingRate
No
String
Supported sampling rate for audio recording.
codec
No
String
Supported 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
} 

Name

Required

Type

Description

maxWidth

Yes

Number

Maximum width that camera device supports for video recording

maxHeight

Yes

Number

Maximum 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
} 

Name

Required

Type

Description

maxWidth

Yes

Number

Maximum width that camera device supports for picture taking

maxHeight

Yes

Number

Maximum height that camera device supports for picture taking

No Headings