Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to take screenshot in flutter? #69

Closed
suriyaKalidoss123 opened this issue Feb 25, 2020 · 24 comments
Closed

How to take screenshot in flutter? #69

suriyaKalidoss123 opened this issue Feb 25, 2020 · 24 comments

Comments

@suriyaKalidoss123
Copy link

During video call when I'm trying to take screenshot programmatically in flutter. Only a black screen appears. Please provide a solution to take a screenshot.

@plutoless
Copy link
Contributor

how did you do the screenshot? could you pls share your code?

@suriyaKalidoss123
Copy link
Author

suriyaKalidoss123 commented Mar 2, 2020

replace this below code with flutter main.dart sample
videocall.zip
Agora rtc version:agora_rtc_engine: ^1.0.7
Also tried using this plugin: screenshot: ^0.1.1
but still, the issue occurs
For more details refer this stack link:https://stackoverflow.com/questions/60426884/how-to-take-screenshot-in-flutter-during-video-call

@LichKing-2234
Copy link
Contributor

I add the code of screenshot only, and I see it worked, pls check your code.
or you can try my code
call.dart.zip

@suriyaKalidoss123
Copy link
Author

suriyaKalidoss123 commented Mar 2, 2020

@LichKing-2234 i had tried your code but still the black screen issue occurs
image
Please save the image and check
Future<void> _capturePng() { return new Future.delayed(const Duration(milliseconds: 20), () async { try { RenderRepaintBoundary boundary = rootWidgetKey.currentContext.findRenderObject(); var image = await boundary.toImage(pixelRatio: 3.0); ByteData byteData = await image.toByteData(format: ImageByteFormat.png); Uint8List pngBytes = byteData.buffer.asUint8List(); final result = await ImageGallerySaver.saveImage(pngBytes); return pngBytes; //这个对象就是图片数据 } catch (e) { print(e); } }); }

@LichKing-2234
Copy link
Contributor

@suriyaKalidoss123
Copy link
Author

@LichKing-2234 nope join channel method called on the page initialize.So changing the page state does not call join channel twice. Are you facing this issue?

@LichKing-2234
Copy link
Contributor

by the way, your device is Android or iOS?

@suriyaKalidoss123
Copy link
Author

by the way, your device is Android or iOS?

Android

@LichKing-2234
Copy link
Contributor

I think I misunderstood you. The picture in this album is black, but the app works fine?

@suriyaKalidoss123
Copy link
Author

I think I misunderstood you. The picture in this album is black, but the app works fine?

yep, the plugin is working fine. But I can't able to take a screenshot due to the black screen issue.

@LichKing-2234
Copy link
Contributor

because we use SurfaceView to render the video, screenshot is not worked for SurfaceView

@suriyaKalidoss123
Copy link
Author

@LichKing-2234 absolutely correct, Is there is any alternatives for this issue?

@LichKing-2234
Copy link
Contributor

your can try TextureView, but you need fork our code and modify it

@suriyaKalidoss123
Copy link
Author

your can try TextureView, but you need fork our code and modify it

which code?

@LichKing-2234
Copy link
Contributor

@LichKing-2234
Copy link
Contributor

LichKing-2234 commented Mar 3, 2020

Android code like this
AgoraTextureView render = new AgoraTextureView(context); render.init(null); render.setBufferType(MediaIO.BufferType.BYTE_ARRAY); render.setPixelFormat(MediaIO.PixelFormat.I420); rtcEngine().setLocalVideoRenderer(render); rtcEngine().setRemoteVideoRenderer(uid, otherRender);

@LichKing-2234
Copy link
Contributor

I will close this issue because it is too old. if there are still problems, you can reopen this issue.

@agungsb
Copy link

agungsb commented May 10, 2020

@LichKing-2234 Can you please provide an example of how to achieve that in Flutter?

My guess is that I need setExternalVideoSource method but I can't find it in AgoraRTCEngine

https://docs.agora.io/en/Video/custom_video_android?platform=Android

@agungsb
Copy link

agungsb commented May 10, 2020

I see on https://github.com/AgoraIO/Flutter-SDK/tree/master/android/src/main/java/io/agora/agorartcengine , it only supports SurfaceView for Flutter. Any chance to add TextureView?

@LichKing-2234
Copy link
Contributor

@LichKing-2234 Can you please provide an example of how to achieve that in Flutter?

My guess is that I need setExternalVideoSource method but I can't find it in AgoraRTCEngine

https://docs.agora.io/en/Video/custom_video_android?platform=Android

You should add it into the java code

@LichKing-2234
Copy link
Contributor

I see on https://github.com/AgoraIO/Flutter-SDK/tree/master/android/src/main/java/io/agora/agorartcengine , it only supports SurfaceView for Flutter. Any chance to add TextureView?

We have planed to add TextureView.

@suriyaKalidoss123
Copy link
Author

suriyaKalidoss123 commented Jul 4, 2020

@LichKing-2234 Is the issue fixed? Please provide some workaround to fix these issues, Screenshot is mandatory in the video call app.

@Meherdeep
Copy link
Contributor

Hi, for anyone who's still facing this issue : I was able to take the screenshot of my stream using this package https://pub.dev/packages/native_screenshot

You can simply run this function to take the screenshot of your stream:

Future<void> _capturePng() async {
    String path = await NativeScreenshot.takeScreenshot();
    print(path);
  }

You can find the complete code here: https://github.com/Meherdeep/agora-videocall-demo

@TungWang
Copy link

Hi, for anyone who's still facing this issue : I was able to take the screenshot of my stream using this package https://pub.dev/packages/native_screenshot

You can simply run this function to take the screenshot of your stream:

Future<void> _capturePng() async {
    String path = await NativeScreenshot.takeScreenshot();
    print(path);
  }

You can find the complete code here: https://github.com/Meherdeep/agora-videocall-demo

Is it working on iOS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants