Open magnuswikhog opened 2 years ago
Hi Magnus!
I faced the same problem, could extract the aspect ratio from the videoPlayerController
.
Example:
void initState() {
final betterPlayerDataSource =
BetterPlayerDataSource(BetterPlayerDataSourceType.network, widget.videoUrl);
betterPlayerController = BetterPlayerController(
betterPlayerDataSource: betterPlayerDataSource,
);
betterPlayerController?.addEventsListener((BetterPlayerEvent event) {
if (event.betterPlayerEventType == BetterPlayerEventType.initialized) {
betterPlayerController
?.setOverriddenAspectRatio(betterPlayerController!.videoPlayerController!.value.aspectRatio);
setState(() {});
}
});
Hi Magnus!
I faced the same problem, could extract the aspect ratio from the
videoPlayerController
.Example:
void initState() { final betterPlayerDataSource = BetterPlayerDataSource(BetterPlayerDataSourceType.network, widget.videoUrl); betterPlayerController = BetterPlayerController( betterPlayerDataSource: betterPlayerDataSource, ); betterPlayerController?.addEventsListener((BetterPlayerEvent event) { if (event.betterPlayerEventType == BetterPlayerEventType.initialized) { betterPlayerController ?.setOverriddenAspectRatio(betterPlayerController!.videoPlayerController!.value.aspectRatio); setState(() {}); } });
Thanks for the solution, it works! It is really unexpected that the aspect ratio is not calculated by BetterPlayer, since this functionality is present in the video_player and chewie projects.
Is your feature request related to a problem? Please describe. I'm loading videos from online (Firebase Storage), the aspect ratio could be different for each video, so I can't set it manually. I was expecting BetterPlayer to automatically detect the aspect ratio and resize the widget accordingly, but I can't find any info on how to do it. Everything related to aspect ratios that I find is either just related to fullscreen, or examples where the aspect ratio is hard coded.
Describe the solution you'd like I'm 99% sure that info about aspect ratio is in the video files, so the expected default behaviour would be that the widget sizes itself accordingly (after loading/buffering the video of course).
Describe alternatives you've considered Not sure what my alternatives would be. I can't hard code aspect ratios since they could be different from one video to another. Maybe I could store the information somewhere (in the filename, in Firebase, etc), but that seems like a super hacky way of accomplishing something that should be a no-brainer in 2022...
Additional context