apivideo / api.video-flutter-live-stream

Flutter RTMP live stream client. Made with ♥ by api.video
MIT License
70 stars 41 forks source link

aspect Ratio is not correctly retrieved #28

Closed sirwes closed 1 year ago

sirwes commented 1 year ago

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.

ThibaultBee commented 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.

sirwes commented 1 year ago

On Android, there's no complete app crash, but the image is distorted because the aspect ratio is always 1 (the default)

ThibaultBee commented 1 year ago

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?

sirwes commented 1 year ago

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; } }

ThibaultBee commented 1 year ago

Hi,

Did you find a solution to your issue?

sirwes commented 1 year ago

Yeah, the workaround I pointed out earlier did the trick, still not sure why

ThibaultBee commented 1 year ago

@sirwes Is this issue resolved in 1.1.2?

ThibaultBee commented 1 year ago

Hi, It looks like a stalled issue -> Closing. Please reopen it if it is not fixed.