8000 Allow optional aspect ratio handling in RTCVideoView · Issue #1835 · flutter-webrtc/flutter-webrtc · GitHub 8000
[go: up one dir, main page]

Skip to content
Allow optional aspect ratio handling in RTCVideoView #1835
Open
@ygalbrami

Description

@ygalbrami

Feature Request: Optional Aspect Ratio Handling in RTCVideoView

if I use this on full screen it will zoom In and it will cut the outside video, so i have remove the aspect ratio
and starch video width and height.
as i use it for streaming my screen i create my own source.

What I Did

I modified the RTCVideoView widget to allow full-screen rendering without being constrained by the video's aspect ratio. The original implementation used a SizedBox with dimensions based on the aspectRatio, which made it difficult to achieve flexible layouts like full-screen views.

In my customized version, I removed the aspect ratio logic and instead used the full available height and width from LayoutBuilder. I replaced the internal sizing logic with this:

FittedBox(
          // clipBehavior: Clip.hardEdge,
          fit: objectFit == RTCVideoViewObjectFit.RTCVideoViewObjectFitContain
              ? BoxFit.contain
              : BoxFit.fill, //change it to fill,
          child: Center(
            child: ValueListenableBuilder<RTCVideoValue>(
              valueListenable: videoRenderer,
              builder:
                  (BuildContext context, RTCVideoValue value, Widget? child) {
                return SizedBox(
                  width: constraints.maxHeight, //* value.aspectRatio,
                  height: constraints.maxHeight,
                  child: child,
                );
              },
              child: Transform(
                transform: Matrix4.identity()..rotateY(mirror ? -pi : 0.0),
                alignment: FractionalOffset.center,
                child: videoRenderer.renderVideo
                    ? Texture(
                        textureId: videoRenderer.textureId!,
                        filterQuality: filterQuality,
                      )
                    : placeholderBuilder?.call(context) ?? Container(),
              ),
            ),
          ),
        ),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0