Open h-unterp opened 1 year ago
i have the same question,I want to know how to solve this problem
do you have any solution to this problem? @jhomlala How we can solve this problem
Any update?
Same issue here, on entering full screen on chat (flutter_chat_ui), it's disposing video player controller and throwing setState error
I had a similar issue with my project.
If you are using list view with player, then please investigate whether your list item widget is kept or not. I mean finding out if it's disposed and initialized again.
I just made a list view by myself with SliverList
, and list item widget was just disposed by framework right after entering better player's full screen mode.
So widget tree is locked due to widget's disposal, though, BetterPlayerController
is still working and its state is keeping changed.
In this case, you'd better implement AutomaticKeepAliveClientMixin
for widget which contains BetterPlayerController
.
You can override wantKeepAlive
as true to prevent widget from disposal.
@override
bool get wantKeepAlive => isVideoFullScreen;
When you use flag, then must let flutter know it's updated using updateKeepAlive
.
switch (event.betterPlayerEventType) {
case BetterPlayerEventType.openFullscreen:
debugPrint(
'openFullscreen: ${event.betterPlayerEventType}, ${_betterPlayerController!.isFullScreen}');
// Keep Alive as true to prevent widget disposed during full view
isVideoFullScreen = true;
updateKeepAlive();
break;
case BetterPlayerEventType.hideFullscreen:
debugPrint(
'hideFullscreen: ${event.betterPlayerEventType}, ${_betterPlayerController!.isFullScreen}');
// Keep Alive as true until completing back to normal video view
Future.delayed(const Duration(seconds: 3), () {
isVideoFullScreen = false;
updateKeepAlive();
});
break;
default:
break;
}
History check I am aware of https://github.com/jhomlala/betterplayer/issues/673 However, I copied the example from https://github.com/jhomlala/betterplayer/tree/master/example/lib/pages/video_list You will see my code is nearly 1:1 with your example.
See how I am calling VideoListWidget: https://github.com/h-unterp/better_scroll/blob/4a91bace0eb309e353fa72439b6b398d33fa55c3/lib/easy_example.dart#L55
Describe the bug Combining https://github.com/ftognetto/riverpod_infinite_scroll with better player Scroll down a few dozen (0-30) videos and you will see the bug.
To Reproduce Steps to reproduce the behavior:
Screenshots
Flutter doctor
Better Player version