<camera>
A camera object that can be displayed on a video view and/or broadcast to an rtmpserver.

JavaScript: lz.camera
extends <mediadevice> » <node> » lz.Eventable »

In order to use a camera in an LZX application, the visible and allowed attributes must be set to true. The visible indicates the program's intent and the allowed attribute indicates the user's permission. To protect privacy, camera operation must be explicitly approved by the user.

    <canvas height="100">
        <camera id="rtc" src="rtmp://localhost/test" autoconnect="false"/>
        <text text="${rtc.status}"/>
        <button onclick="rtc.connect()">Click to Connect</button>
    </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
bandwidth expression any 16384 read/write
  Camera bandwidth (in bytes per second).
favorsize expression any false read/write
  Often several capture modes are available per camera device. These modes will allow capturing at a specific size (width/height) and framerate. If you specify both fps and width and height for this camera, this attribute will control which capturing mode for the camera device will be used.
fps expression any null read/write
  The number of frames per second that will be captured by the camera.
height expression any null read/write
  The height (resolution) that will be captured by the camera.
picturequality expression any 0 read/write
  Camera picture quality: a value between 0 and 1, where 1 represents the highest quality (no compression). When 0 is passed, this indicates to use highest quality that fits into the available bandwidth
show expression any false read/write
  If true, show camera on immediateparent videoview.
width expression any null read/write
  The width (resolution) that will be captured by the camera.

Methods

destroy()
camera.destroy();

getCameraNames()
camera.getCameraNames();
Get the names of the cameras. Returns an array of strings. This might take a while to run, since it has to scan the devices.

setMode()
camera.setMode(width, height, fps, favorsize);
setMode(width, height, fps, favorsize) width, height, fps: number favorsize: A Boolean value that specifies how to manipulate the width, height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default is true, which means that maintaining capture size is favored; using this parameter selects the mode that most closely matches width and height values, even if doing so adversely affects performance by reducing the frame rate. To maximize frame rate at the expense of camera height and width, pass false for the favorSize parameter. This parameter is optional. The parameters are cached in the attributes width, height, fps and favorsize. TODO: If those attributes are not null, then call setMode automatically after initializing camera. Otherwise read values from camera and set attributes.
Parameter Name Type Description
width    
height    
fps    
favorsize    

setQuality()
camera.setQuality(bandwidth, picturequality);
setQuality(bandwidth, picturequality"); bandwidth: in byte per second, default value: 16384 picturequality: number from 0 to 1, default value: 0 0 means also that picturequality will be changed if bandwidth is concerned. The parameters are cached in the attributes bandwidth and picturequality. TODO: If those attributes are set, then call setQuality automatically after initializing camera. Otherwise read values from camera and set attributes.
Parameter Name Type Description
bandwidth    
picturequality    

startDevice()
camera.startDevice();
Start the camera.

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy