kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix video_control sizing calc for VideoPlayerLibAvControl.
rodzic
6de89aef26
commit
2456ee9d38
|
@ -56,24 +56,19 @@ class _VideoPlayerLibAvControlState extends State<VideoPlayerLibAvControl> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = videoPlayerController.value.size;
|
||||
final horizontalScale = size.width / widget.width;
|
||||
final verticalScale = size.height / widget.height;
|
||||
final scaling = min(horizontalScale, verticalScale);
|
||||
final videoWidth = scaling * size.width;
|
||||
final videoHeight = scaling * size.height;
|
||||
|
||||
if (!videoPlayerController.value.isInitialized) {
|
||||
return SizedBox(
|
||||
width: videoWidth,
|
||||
height: videoHeight,
|
||||
child: const Card(
|
||||
color: Colors.black12,
|
||||
shape: RoundedRectangleBorder(),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
late final double videoWidth;
|
||||
late final double videoHeight;
|
||||
if (needsToLoad) {
|
||||
videoWidth = widget.width;
|
||||
videoHeight = widget.height;
|
||||
} else {
|
||||
final horizontalScale = widget.width / size.width;
|
||||
final verticalScale = widget.height / size.height;
|
||||
final scaling = min(horizontalScale, verticalScale);
|
||||
videoWidth = scaling * size.width;
|
||||
videoHeight = scaling * size.height;
|
||||
}
|
||||
|
||||
print('Video Width: $videoWidth, Video Height: $videoHeight');
|
||||
return GestureDetector(
|
||||
onTap: toggleVideoPlay,
|
||||
child: Column(
|
||||
|
@ -82,10 +77,14 @@ class _VideoPlayerLibAvControlState extends State<VideoPlayerLibAvControl> {
|
|||
SizedBox(
|
||||
width: videoWidth,
|
||||
height: videoHeight,
|
||||
child: AspectRatio(
|
||||
aspectRatio: videoPlayerController.value.aspectRatio,
|
||||
child: VideoPlayer(videoPlayerController),
|
||||
),
|
||||
child: needsToLoad
|
||||
? Container(
|
||||
color: Colors.black,
|
||||
)
|
||||
: AspectRatio(
|
||||
aspectRatio: videoPlayerController.value.aspectRatio,
|
||||
child: VideoPlayer(videoPlayerController),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
|
|
Ładowanie…
Reference in New Issue