Package org.zkoss.zkmax.zul
Class Camera
java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zkmax.zul.Camera
- All Implemented Interfaces:
Serializable,Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl
public class Camera
extends org.zkoss.zul.impl.XulElement
A camera, use to record video and take snapshot, have a preview screen.
Only works for browsers supporting HTML5 video tag
- Since:
- 8.6.0
- Author:
- charlesqiu
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRepresent the pause statestatic final intRepresent the resume statestatic final intRepresent the start statestatic final intRepresent the stop stateFields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the constraints.Returns the constraints in JSON String format.intGet the maximum record length limit, unit is "seconds".intGet the max size setting of upload video and snapshot, unit is "KB".Get the record video format, e.g., video/webm, video/mp4, video/ogg.Get the snapshot image format, e.g., image/png, image/jpeg.booleanisAudio()Return whether to record sound while recording video.booleanisPaused()Return whether camera is paused.booleanReturn whether the preview screen is on.booleanReturn whether camera is recording.booleanReturn whether camera is stopped.voidpause()Pause recording.protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) voidAsk user for permissions to get media stream from camera and microphone.voidresume()Resume recording.voidservice(org.zkoss.zk.au.AuRequest request, boolean everError) voidsetAudio(boolean audio) Set whether to record sound while recording video.voidsetConstraints(Map constraints) Sets the constraints, if not specify constraints, it will use {audio:isAudio(), video: true}.voidsetConstraintsString(String constraints) Sets the constraints in JSON String format, if not specify constraints, it will use {audio:isAudio(), video: true}.voidsetLengthLimit(int lengthLimit) Set the maximum record length limit, unit is "seconds".voidsetMaxsize(int maxsize) Set the max size of upload video and snapshot, unit is "KB".voidsetPreviewRecord(boolean previewRecord) Set whether the preview screen is on.voidsetRecordFormat(String recordFormat) Set the record video format, e.g., video/webm, video/mp4, video/ogg.voidsetRecording(boolean recording) setRecording(true) means start or resume recording.voidsetSnapshotFormat(String snapshotFormat) Set the snapshot image format, e.g., image/png, image/jpeg.voidsnapshot()Take a snapshot.voidsnapshot(double delay) Take a snapshot.voidstart()Start recording.voidstart(double delay) Start recording.voidstop()Stop recording.voidStop getting media stream from user's camera and microphone.Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Field Details
-
STOP
public static final int STOPRepresent the stop state- See Also:
-
START
public static final int STARTRepresent the start state- See Also:
-
PAUSE
public static final int PAUSERepresent the pause state- See Also:
-
RESUME
public static final int RESUMERepresent the resume state- See Also:
-
-
Constructor Details
-
Camera
public Camera()
-
-
Method Details
-
start
public void start()Start recording. -
start
public void start(double delay) Start recording. When camera is off (never call $requestCamera()before), after calling this method, it will request camera permission from user at first, the delay parameter indicates the duration between user permission obtaining and record starting in seconds.- Parameters:
delay- the duration between user permission obtaining and record starting in seconds, only meaningful when camera is off
-
stop
public void stop()Stop recording. -
pause
public void pause()Pause recording. -
resume
public void resume()Resume recording. -
snapshot
public void snapshot()Take a snapshot. -
snapshot
public void snapshot(double delay) Take a snapshot. When camera is off (never call $requestCamera()before), after calling this method, it will request camera permission from user at first, the delay parameter indicates the duration between user permission obtaining and taking snapshot in seconds.- Parameters:
delay- the duration between user permission obtaining and taking snapshot in seconds, only meaningful when camera is off
-
requestCamera
public void requestCamera()Ask user for permissions to get media stream from camera and microphone. -
stopStreaming
public void stopStreaming()Stop getting media stream from user's camera and microphone. -
service
public void service(org.zkoss.zk.au.AuRequest request, boolean everError) - Specified by:
servicein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
servicein classorg.zkoss.zk.ui.HtmlBasedComponent
-
renderProperties
- Overrides:
renderPropertiesin classorg.zkoss.zul.impl.XulElement- Throws:
IOException
-
isStopped
public boolean isStopped()Return whether camera is stopped.- Returns:
- true if the camera is stopped.
-
isPaused
public boolean isPaused()Return whether camera is paused.- Returns:
- true if the camera is paused.
-
isRecording
public boolean isRecording()Return whether camera is recording.- Returns:
- true if the camera is recording.
-
setRecording
public void setRecording(boolean recording) setRecording(true) means start or resume recording. setRecording(false) means stop recording. If you want to pause recording, please invokepause().- Parameters:
recording- whether to start recording.
-
isAudio
public boolean isAudio()Return whether to record sound while recording video.Default: true
- Returns:
- true if record sound function is on.
-
setAudio
public void setAudio(boolean audio) Set whether to record sound while recording video.- Parameters:
audio- whether to record sound.
-
getMaxsize
public int getMaxsize()Get the max size setting of upload video and snapshot, unit is "KB". Refer tosetMaxsize(int)for more details.Default:
Configuration.getMaxUploadSize()- Returns:
- the max size setting.
-
setMaxsize
public void setMaxsize(int maxsize) Set the max size of upload video and snapshot, unit is "KB". Notice: Both video and snapshot files must smaller than max size, or nothing will upload.- Parameters:
maxsize- negative value is unlimited, 0 will useConfiguration.getMaxUploadSize()
-
getLengthLimit
public int getLengthLimit()Get the maximum record length limit, unit is "seconds". If recording seconds exceed length limit, recording will stop immediately.Default: 60
- Returns:
- maximum record length limit setting.
-
setLengthLimit
public void setLengthLimit(int lengthLimit) Set the maximum record length limit, unit is "seconds". If recording seconds exceed length limit, recording will stop immediately.- Parameters:
lengthLimit- setting maximum record length limit.
-
isPreviewRecord
public boolean isPreviewRecord()Return whether the preview screen is on. If you want to take a snapshot, must turn on preview screen, or nothing will happen.Default: true
- Returns:
- true if preview screen is on.
-
setPreviewRecord
public void setPreviewRecord(boolean previewRecord) Set whether the preview screen is on. If you want to take a snapshot, must turn on preview screen, or nothing will happen.- Parameters:
previewRecord- whether to turn on preview screen.
-
getSnapshotFormat
Get the snapshot image format, e.g., image/png, image/jpeg. If the requested type is invalid or unspecified, it will use image/png.Default: null.
- Returns:
- snapshot format
-
setSnapshotFormat
Set the snapshot image format, e.g., image/png, image/jpeg. If the requested type is invalid or unspecified, it will use image/png.- Parameters:
snapshotFormat- snapshot format
-
getRecordFormat
Get the record video format, e.g., video/webm, video/mp4, video/ogg. If the requested type is invalid or unspecified, it will use video/webm.Default: null.
- Returns:
- recordFormat format
-
setRecordFormat
Set the record video format, e.g., video/webm, video/mp4, video/ogg. If the requested type is invalid or unspecified, it will use video/webm.- Parameters:
recordFormat- recordFormat format
-
getConstraints
Returns the constraints. About allowed constraints setting, see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints Default: null.- Returns:
- the constraints
-
setConstraints
Sets the constraints, if not specify constraints, it will use {audio:isAudio(), video: true}. About allowed constraints setting, see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints- Parameters:
constraints- the constraints
-
getConstraintsString
Returns the constraints in JSON String format. About allowed constraints setting, see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraintsDefault: null.
- Returns:
- the constraints in JSON String format
-
setConstraintsString
Sets the constraints in JSON String format, if not specify constraints, it will use {audio:isAudio(), video: true}. About allowed constraints setting, see https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamConstraints- Parameters:
constraints- the constraints in JSON String format
-