Package com.storedobject.vaadin
Class VideoCapture
java.lang.Object
com.vaadin.flow.component.Component
com.storedobject.vaadin.Media
com.storedobject.vaadin.Video
com.storedobject.vaadin.VideoCapture
- All Implemented Interfaces:
HasSize,MediaCapture,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
A special
Video class that gets input from the client Computer's camera. The video stream from the
camera can be (1) just viewed or (2) streamed to the server and saved. Also, snap-shot of the
video stream can be taken as a picture and the resulting image can be just viewed or saved to the server.- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.storedobject.vaadin.MediaCapture
MediaCapture.DataReceiver, MediaCapture.StatusChangeListener -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.VideoCapture(com.vaadin.flow.component.html.Image image) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationAdd "status change" listener so that we can monitor recording/previewing status.voidattachImage(com.vaadin.flow.component.html.Image image) Attach an image to this video camera so that pictures shot can be viewed on that.Get theApplicationto which this is attached.booleanCheck whether previewing is in progress or not.booleanCheck whether recording is in progress or not.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidpreview()Preview the camera's output on this video component.voidTake snap-shot from the video stream and show that picture on the already attached image componentattachImage(Image).voidpreviewPicture(com.vaadin.flow.component.html.Image image) Take snap-shot from the video stream and show that picture on the given image component.voidsavePicture(MediaCapture.DataReceiver dataReceiver) Take snap-shot from the video stream, show that picture on the already attached image component and also, save the picture via a "data receiver".voidsavePicture(com.vaadin.flow.component.html.Image image, MediaCapture.DataReceiver dataReceiver) Take snap-shot from the video stream, show that picture on the given image component and also, save the picture via a "data receiver".voidSelect the front camera if possible.voidSelect the rear camera if possible.voidstartRecording(MediaCapture.DataReceiver dataReceiver) Start the recording of the video stream to a "data receiver".voidStop / switch off the camera (activities such as previewing, recording etc. will be stopped).voidStop the recording of the video stream that may be currently in progress.Methods inherited from class com.storedobject.vaadin.Media
addSource, addSource, clear, setSource, setSource, showControlsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.storedobject.vaadin.MediaCapture
addSource, clear, setSource
-
Constructor Details
-
VideoCapture
public VideoCapture()Constructor. -
VideoCapture
public VideoCapture(com.vaadin.flow.component.html.Image image) Constructor.- Parameters:
image- Image to be attached for previewing the snap-shots
-
-
Method Details
-
onAttach
-
onDetach
-
selectFrontCamera
public void selectFrontCamera()Select the front camera if possible. (This should be done before theVideoCapturecomponent is added to the layout). -
selectRearCamera
public void selectRearCamera()Select the rear camera if possible. (This should be done before theVideoCapturecomponent is added to the layout). -
getApplication
Get theApplicationto which this is attached.- Specified by:
getApplicationin interfaceMediaCapture- Returns:
- The application.
-
attachImage
public void attachImage(com.vaadin.flow.component.html.Image image) Attach an image to this video camera so that pictures shot can be viewed on that. (Image should be somewhere on the screen when the actual preview is requested on this image usingpreviewPicture()).- Parameters:
image- The image component on which picture should be displayed
-
preview
public void preview()Preview the camera's output on this video component. The output will be visible only if the following conditions are satisfied:
(1) The component is already on the screen (by adding to some layout in your application) and visible.
(2) The camera on the client computer can be accessed (browser will prompt the user for providing access).
(3) Your application is using https protocol and not just http protocol (Modern browsers do not allow camera access when a site is using http protocol).
(4) If recording is not active already. -
previewPicture
public void previewPicture()Take snap-shot from the video stream and show that picture on the already attached image componentattachImage(Image). The output will be visible only if the previewing is already active. -
previewPicture
public void previewPicture(com.vaadin.flow.component.html.Image image) Take snap-shot from the video stream and show that picture on the given image component. The output will be visible only if the previewing is already active and the image is already somewhere on the same screen.- Parameters:
image- The image component on which picture should be displayed
-
savePicture
Take snap-shot from the video stream, show that picture on the already attached image component and also, save the picture via a "data receiver". The output will be visible and saved only if the previewing is already active.- Parameters:
dataReceiver- Data receiver to receive the picture stream
-
savePicture
public void savePicture(com.vaadin.flow.component.html.Image image, MediaCapture.DataReceiver dataReceiver) Take snap-shot from the video stream, show that picture on the given image component and also, save the picture via a "data receiver". The output will be visible and saved only if the previewing is already active.- Parameters:
image- The image component on which picture should be displayeddataReceiver- Data receiver to receive the picture stream
-
startRecording
Start the recording of the video stream to a "data receiver".- Specified by:
startRecordingin interfaceMediaCapture- Parameters:
dataReceiver- Data receiver to receive the video stream
-
isRecording
public boolean isRecording()Check whether recording is in progress or not.- Specified by:
isRecordingin interfaceMediaCapture- Returns:
- True or false.
-
stopRecording
public void stopRecording()Stop the recording of the video stream that may be currently in progress.- Specified by:
stopRecordingin interfaceMediaCapture
-
isPreviewing
public boolean isPreviewing()Check whether previewing is in progress or not.- Specified by:
isPreviewingin interfaceMediaCapture- Returns:
- True or false.
-
stopDevice
public void stopDevice()Stop / switch off the camera (activities such as previewing, recording etc. will be stopped).- Specified by:
stopDevicein interfaceMediaCapture
-
addStatusChangeListener
public com.vaadin.flow.shared.Registration addStatusChangeListener(MediaCapture.StatusChangeListener listener) Add "status change" listener so that we can monitor recording/previewing status.- Specified by:
addStatusChangeListenerin interfaceMediaCapture- Parameters:
listener- Listener to add- Returns:
- Registration that can be used to remove the listener.
-