jhomlala / betterplayer

Better video player for Flutter, with multiple configuration options. Solving typical use cases!
Apache License 2.0
895 stars 938 forks source link

[BUG] fit property is ignored #1229

Open Cteq3132 opened 1 year ago

Cteq3132 commented 1 year ago

History check Please confirm that you've checked issues history and you didn't find anything which may solve your issue. ✅

Describe the bug ' BetterPlayerConfiguration' 's fit property does not affect the video's fit.

To Reproduce Steps to reproduce the behavior:

  1. Copy the following code
  2. Run the app
  3. See the error : image

*Example code

import 'package:better_player/better_player.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const Scaffold(
        body: Center(
          child: AspectRatio(
            aspectRatio: 1,
            child: ColoredBox(
              color: Colors.red,
              child: VideoWidget(),
            ),
          ),
        ),
      ),
    );
  }
}

class VideoWidget extends StatelessWidget {
  const VideoWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return BetterPlayer.network(
      'https://static.apidae-tourisme.com/filestore/objets-touristiques/videos/237/148/18060525/Mountain+Cart+LP.mp4',
      betterPlayerConfiguration: const BetterPlayerConfiguration(
        fit: BoxFit.cover,
        looping: true,
        fullScreenByDefault: false,
        autoPlay: true,
        controlsConfiguration: BetterPlayerControlsConfiguration(
          showControls: false,
        ),
      ),
    );
  }
}

Expected behavior The video has an aspect ratio of 1.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.79.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Better Player version

Smartphone (please complete the following information):

Additional context The video provided is a 16/9 format

Cteq3132 commented 1 year ago

Ok it seems that with the property expandToFill: false, the 'bug' is fixed : image

But in this case @jhomlala, I'm not sure to understand the doc on this prop, shouldn't it be the opposite ?

Capture d’écran 2023-07-04 à 22 40 41