flutter betterplayer get aspect ratio
To get the aspect ratio in Flutter using the "better_player" package, you can use the BetterPlayerController
class and its videoPlayerController.value.aspectRatio
property. Here's an example:
import 'package:better_player/better_player.dart';
// Create an instance of BetterPlayerController
BetterPlayerController _betterPlayerController = BetterPlayerController(
BetterPlayerConfiguration(),
betterPlayerDataSource: BetterPlayerDataSource(
BetterPlayerDataSourceType.network,
"https://example.com/video.mp4",
),
);
// Get the aspect ratio
double aspectRatio = _betterPlayerController.videoPlayerController.value.aspectRatio;
In this example, we import the better_player
package and create an instance of BetterPlayerController
with a BetterPlayerConfiguration
and a BetterPlayerDataSource
. Then, we access the aspectRatio
property of the videoPlayerController.value
to get the aspect ratio.
Please note that you'll need to replace the video URL ("https://example.com/video.mp4") with your own video URL.