Closed sirwes closed 1 year ago
Hi,
Do you face a crash then? For iOS or Android? Could you just fill the issue template?
In that case, we are not insterested by the aspect ratio of the screen but by the aspect ratio of the video preview.
On Android, there's no complete app crash, but the image is distorted because the aspect ratio is always 1 (the default)
Hi,
I have check your issue and can't reproduce it. I have put a breakpoint in CameraPreview
_updateAspectRatio
method and the size
parameter is always valid.
In Android, the width and height are converted to Double (see https://github.com/apivideo/api.video-flutter-live-stream/blob/2adfa3451e81b94ca2bb8b0c85aa90a981e652e4/android/src/main/kotlin/video/api/flutter/livestream/FlutterLiveStreamView.kt#L67)
Do you use 1.1.1
version?
Am I missing something?
Yes, I was using 1.1.1. I'm not sure why it's giving me an int seeing how that's a double. I'm using flutter v 3.7.0. I adjusted the code to this, and it started working.
Is it possible that the map stores it as an int if the number is round?
@override Future<Size?> getVideoSize() async { final Map<dynamic, dynamic> reply = await _channel.invokeMethod('getVideoSize') as Map; if (reply.containsKey("width") && reply.containsKey("height")) { return Size((reply["width"] as int).toDouble(), (reply["height"] as int).toDouble()); } else { return null; } }
Hi,
Did you find a solution to your issue?
Yeah, the workaround I pointed out earlier did the trick, still not sure why
@sirwes Is this issue resolved in 1.1.2?
Hi, It looks like a stalled issue -> Closing. Please reopen it if it is not fixed.
in the src/apivideo_live_stream_mobile_platform.dart file in the getVideoSize function, you retrieve the Size from the Map "reply". They contain integers so the "as double" type cast is invalid. Instead, cast them to ints and do the "toDouble()" command to get them into double format. Because of this error, the aspect ratio is not updating properly.
Additionally, you should consider using MediaQuery.of(context).size.aspectRatio to get the aspect ratio of the screen if this implementation is in flutter.