takeSnapshot method

  1. @override
Future<void> takeSnapshot(
  1. String channel,
  2. int uid,
  3. String filePath
)

Takes a snapshot of a video stream.

Since v4.2.0

This method takes a snapshot of a video stream from the specified user, generates a JPG image, and saves it to the specified path.

The method is asynchronous, and the SDK has not taken the snapshot when the method call returns. After a successful method call, the SDK triggers the RtcEngineEventHandler.snapshotTaken callback to report whether the snapshot is successfully taken as well as the details of the snapshot taken.

Note

  • Call this method after joining a channel.
  • If the video of the specified user is pre-processed, for example, added with watermarks or image enhancement effects, the generated snapshot also includes the pre-processing effects.

Parameter channel The channel name.

Parameter uid The user ID of the user. Set uid as 0 if you want to take a snapshot of the local user's video.

Parameter filePath The local path (including the filename extensions) for the snapshot. For example, /storage/emulated/0/Android/data/<package name>/files/example.jpg for Android and /App Sandbox/Library/Caches/example.jpg for iOS. Ensure that the path you specify exists and is writable.

Implementation

@override
Future<void> takeSnapshot(String channel, int uid, String filePath) {
  return _invokeMethod('takeSnapshot', {
    'channel': channel,
    'uid': uid,
    'filePath': filePath,
  });
}