title | nav |
---|---|
Capture Snapshot |
10.1 |
You can capture a snapshot of the video stream of a local or remote peer's video.
SDK version 1.3.0
You can capture a snapshot of the video stream of a local or remote peer's video. To capture a snapshot, you call captureSnapshot()
method on HMSVideoTrack
instance to get a Uint8List
containing a snapshot of the video stream.
HMSVideoTrack videoTrack;
...
//Capture snapshot will return a nullable Uint8List type.
Uint8List? bytes = await videoTrack.captureSnapshot();
To display an image use Image.memory
widget which will take Uint8List
as a parameter and return an Image
widget.
//Show Image in Image Widget
if (bytes != null) {
Image imageWidget = Image.memory(bytes);
//Show image widget in widget tree.
}
To save an image in gallery use a 3rd Party plugin image_gallery_saver
which will take Uint8List
as one of the parameter and save a image in gallery directly.
//Save Image in Gallery
if (bytes != null) {
Map result = await ImageGallerySaver.saveImage(bytes, quality: 100, name: "imageName");
//Use 3rd Party Plugin image_gallery_saver to save image in gallery.
}
To know more about
image_gallery_saver
plugin click here.
Checkout the example video implemented in our sample app: