Closed hussenIbrahim closed 2 years ago
This method works fine. Here's example which works with latest BP version (0.0.80):
import 'dart:async';
import 'package:better_player/better_player.dart';
import 'package:better_player_example/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class EventListenerPage extends StatefulWidget {
@override
_EventListenerPageState createState() => _EventListenerPageState();
}
class _EventListenerPageState extends State<EventListenerPage> {
late BetterPlayerController _betterPlayerController;
@override
void initState() {
BetterPlayerConfiguration betterPlayerConfiguration =
BetterPlayerConfiguration(
aspectRatio: 1.0,
deviceOrientationsAfterFullScreen: [
DeviceOrientation.portraitDown,
DeviceOrientation.portraitUp
],
);
BetterPlayerDataSource dataSource = BetterPlayerDataSource(
BetterPlayerDataSourceType.network, Constants.elephantDreamVideoUrl);
_betterPlayerController = BetterPlayerController(betterPlayerConfiguration);
_betterPlayerController.setupDataSource(dataSource);
_betterPlayerController.addEventsListener(_handleEvent);
super.initState();
}
@override
void dispose() {
_betterPlayerController.removeEventsListener(_handleEvent);
super.dispose();
}
void _handleEvent(BetterPlayerEvent event) {
if (event.betterPlayerEventType == BetterPlayerEventType.openFullscreen) {
_betterPlayerController.setOverriddenAspectRatio(16 / 9);
} else if (event.betterPlayerEventType ==
BetterPlayerEventType.hideFullscreen) {
_betterPlayerController.setOverriddenAspectRatio(1.0);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Event listener"),
),
body: Column(
children: [
const SizedBox(height: 8),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Better Player exposes events which can be listened with event "
"listener. Start player to see events flowing.",
style: TextStyle(fontSize: 16),
),
),
const SizedBox(height: 8),
AspectRatio(
aspectRatio: 9 / 16,
child: BetterPlayer(controller: _betterPlayerController),
),
const SizedBox(height: 8),
],
),
);
}
}
aspect ratio not overridden in full screen mode Flutter version 2.8.1 sdk google atv x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator) better_player: ^0.0.81
is there any way to override full screen aspect ratio when video is full screen. i used
setOverriddenAspectRatio
but not works