【问题标题】:How to take screenshot in flutter during video call?如何在视频通话期间拍摄屏幕截图?
【发布时间】:2020-06-11 02:11:56
【问题描述】:

我目前正在使用 agora SDK 进行颤振视频通话。在视频通话期间,我需要截屏。仅在视频通话屏幕上,屏幕截图为黑色,在其他屏幕上屏幕截图正常。 通过使用 RenderRepaintBoundary 我无法截屏,

用于截屏的代码:

Future<void> _capturePng() async {
    try {
      RenderRepaintBoundary boundary =
          _globalKey.currentContext.findRenderObject();
      ui.Image image = await boundary.toImage(pixelRatio: 3.0);
      ByteData byteData =
          await image.toByteData(format: ui.ImageByteFormat.png);
      var pngBytes = byteData.buffer.asUint8List();
      final result = await ImageGallerySaver.saveImage(pngBytes);
    } catch (e) {
      print(e);
    }  }  Widget build(BuildContext context) {
    return RepaintBoundary(
        key: _globalKey,
        child: Scaffold(
            backgroundColor: Colors.black,
            body: GestureDetector(
                onDoubleTap: () => _capturePng(),
                child: Screenshot(
                  controller: screenshotController,
                  child: Center(
                    child: Stack(
                      children: <Widget>[
                        _viewRows(),
                        _toolbar(),
                      ],
                    ),
                  ),
                ))));
}

问题截图:

工作正常截图:

Agora SDK link

用flutter main.dart 示例替换下面的代码

videocall.zip

Agora rtc 版本:agora_rtc_engine: ^1.0.7

也试过使用这个插件:截图:^0.1.1 但是,问题仍然存在

【问题讨论】:

  • 你找到答案了吗?我相信问题出在视频中。我有同样的问题 tsalking 视频的截图。

标签: flutter dart agora.io


【解决方案1】:

我认为您的屏幕截图代码是正确的。问题可能出在您放置RepaintBoundary 的位置。一般来说,RepaintBoundary 中提供的key 将能够截取它的整个子层次结构。所以我认为解决方案是把你的Widget 渲染成你的直播视频在RepaintBoundary 作为孩子。例如

Widget build(context){
   return RepaintBoundary(
      key: _yourGlobalKey,
      child: _yourLiveVideoFeedWidget
   );
}

【讨论】:

    【解决方案2】:

    我认为你的截图方法声明有问题,这是需要遵循的语法:

    ScreenshotController screenshotController = ScreenshotController();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-08
      • 2014-01-12
      • 1970-01-01
      • 2014-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多