Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/src/widgets/video_track_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class VideoTrackRenderer extends StatefulWidget {
/// wrap the video view in a Center widget (if [fit] is [VideoViewFit.contain])
final bool autoCenter;

final void Function(Size)? onResize;

const VideoTrackRenderer(
this.track, {
this.fit = VideoViewFit.contain,
Expand All @@ -77,6 +79,7 @@ class VideoTrackRenderer extends StatefulWidget {
this.autoDisposeRenderer = true,
this.cachedRenderer,
this.autoCenter = true,
this.onResize,
Key? key,
}) : super(key: key);

Expand Down Expand Up @@ -176,6 +179,20 @@ class _VideoTrackRendererState extends State<VideoTrackRenderer> {
setState(() {});
});
_renderer?.onResize = () {
final videoValue = (_renderer as ValueNotifier<rtc.RTCVideoValue>?)?.value;
if (videoValue == null) {
return;
}
final double width;
final double height;
if (videoValue.rotation % 180 == 0) {
width = videoValue.width;
height = videoValue.height;
} else {
width = videoValue.height;
height = videoValue.width;
}
widget.onResize?.call(Size(width, height));
if (mounted) {
setState(() {
_aspectRatio = (_renderer as rtc.RTCVideoRenderer?)?.videoValue.aspectRatio;
Expand Down