Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8c1225c

Browse files
committed
VideoFrame implements CanvasImageSource
1 parent ed7549c commit 8c1225c

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

lib/web_ui/lib/src/engine/canvaskit/image_web_codecs.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ Future<Uint8List> encodeVideoFrameAsPng(VideoFrame videoFrame) async {
462462
..width = width
463463
..height = height;
464464
final html.CanvasRenderingContext2D ctx = canvas.context2D;
465-
drawVideoFrame(ctx, videoFrame, 0, 0);
465+
ctx.drawImage(videoFrame, 0, 0);
466466
final String pngBase64 = canvas.toDataUrl().substring('data:image/png;base64,'.length);
467467
return base64.decode(pngBase64);
468468
}

lib/web_ui/lib/src/engine/safe_browser_api.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ class DecodeOptions {
304304
/// * https://www.w3.org/TR/webcodecs/#videoframe-interface
305305
@JS()
306306
@anonymous
307-
class VideoFrame {
307+
class VideoFrame implements html.CanvasImageSource {
308308
external int allocationSize();
309309
external JsPromise copyTo(Uint8List destination);
310310
external String? get format;
@@ -1005,7 +1005,3 @@ class OffScreenCanvas {
10051005
static bool get supported => _supported ??=
10061006
js_util.hasProperty(html.window, 'OffscreenCanvas');
10071007
}
1008-
1009-
void drawVideoFrame(html.CanvasRenderingContext2D ctx, VideoFrame videoFrame, int x, int y) {
1010-
js_util.callMethod<void>(ctx, 'drawImage', <Object?>[videoFrame, x, y]);
1011-
}

0 commit comments

Comments
 (0)