#hs.camera

Inspect the system's camera devices


#API Overview

Functions - API calls offered directly by the extension

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Functions

Signaturehs.camera.allCameras() -> table
TypeFunction
DescriptionGet all the cameras known to the system
Parameters
  • None
Returns
  • A table containing all of the known cameras
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 329

Signaturehs.camera.isWatcherRunning() -> Boolean
TypeFunction
DescriptionChecks if the camera devices watcher is running
Parameters
  • None
Returns
  • A boolean, True if the watcher is running, otherwise False
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 468

Signaturehs.camera.setWatcherCallback(fn)
TypeFunction
DescriptionSets/clears the callback function for the camera devices watcher
Parameters
  • fn - A callback function, or nil to remove a previously set callback. The callback should accept a two arguments (see Notes below)
Returns
  • None
Notes
  • The callback will be called when a camera is added or removed from the system
  • To watch for changes within a single camera device, see hs.camera:newWatcher()
  • The callback function arguments are:
  • An hs.camera device object for the affected device
  • A string, either "Added" or "Removed" depending on whether the device was added or removed from the system
  • For "Removed" events, most methods on the hs.camera device object will not function correctly anymore and the device object passed to the callback is likely to be useless. It is recommended you re-check hs.camera.allCameras() and keep records of the cameras you care about
  • Passing nil will cause the watcher to stop if it is running
ExamplesNone
Sourceextensions/camera/libcamera.m line 486

Signaturehs.camera.startWatcher()
TypeFunction
DescriptionStarts the camera devices watcher
Parameters
  • None
Returns
  • None
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 378

Signaturehs.camera.stopWatcher()
TypeFunction
DescriptionStops the camera devices watcher
Parameters
  • None
Returns
  • None
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 435

#Methods

Signaturehs.camera:connectionID() -> String
TypeMethod
DescriptionGet the raw connection ID of the camera
Parameters
  • None
Returns
  • A number containing the connection ID of the camera
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 554

Signaturehs.camera:isInUse() -> Boolean
TypeMethod
DescriptionGet the usage status of the camera
Parameters
  • None
Returns
  • A boolean, True if the camera is in use, otherwise False
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 590

Signaturehs.camera:isPropertyWatcherRunning() -> bool
TypeMethod
DescriptionChecks if the property watcher on a camera object is running
Parameters
  • None
Returns
  • A boolean, True if the property watcher is running, otherwise False
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 691

Signaturehs.camera:name() -> String
TypeMethod
DescriptionGet the name of the camera
Parameters
  • None
Returns
  • A string containing the name of the camera
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 572

| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | hs.camera:setPropertyWatcherCallback(fn) -> hs.camera object | | Type | Method | | Description | Sets or clears a callback for when the properties of an hs.camera object change | | Parameters |

  • fn - A function to be called when properties of the camera change, or nil to clear a previously set callback. The function should accept the following parameters: The hs.camera object that changed A string describing the property that changed. Possible values are: gone - The device's "in use" status changed (ie another app started using the camera, or stopped using it) A string containing the scope of the event, this will likely always be "glob" A number containing the element of the event, this will likely always be "0"
| | Returns |
  • The hs.camera object
| | Notes | None | | Examples | None | | Source | extensions/camera/libcamera.m line 608 |


Signaturehs.camera:startPropertyWatcher()
TypeMethod
DescriptionStarts the property watcher on a camera
Parameters
  • None
Returns
  • The hs.camera object
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 644

Signaturehs.camera:stopPropertyWatcher()
TypeMethod
DescriptionStops the property watcher on a camera
Parameters
  • None
Returns
  • The hs.camera object
NotesNone
ExamplesNone
Sourceextensions/camera/libcamera.m line 671

Signaturehs.camera:uid() -> String
TypeMethod
DescriptionGet the UID of the camera
Parameters
  • None
Returns
  • A string containing the UID of the camera
Notes
  • The UID is not guaranteed to be stable across reboots
ExamplesNone
Sourceextensions/camera/libcamera.m line 533