fluttercommunity / fluttercommunity/chewie
Video src cannot be switched in full-screen mode
- Dominant language
- Dart
- Stars
- 2.1k
- Forks
- 1.1k
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 6
Description
```
Future _initController() async {
var list = widget.list;
var originIndex = widget.originIndex;
var teleplayIndex = widget.teleplayIndex;
final originPlayList = list?[originIndex]?.linkList;
final url = originPlayList?[teleplayIndex].link ?? '';
setState(() {
_loading = true;
_error = false;
});
_videoPlayerController = VideoPlayerController.networkUrl(
Uri.parse(url),
)
..addListener(_listener)
..initialize().then(
(value) {
double? videoAspectRatio = _videoPlayerController?.value.aspectRatio;
setState(() {
_loading = false;
_error = false;
});
_chewieController = ChewieController(
videoPlayerController: _videoPlayerController!,
allowFullScreen: true,
autoPlay: true,
looping: false,
autoInitialize: true,
startAt: Duration(seconds: widget.startAt ?? 0),
showControlsOnInitialize: true,
aspectRatio: videoAspectRatio ?? _aspectRatio,
additionalOptions: (context) {
return [
OptionItem(
onTap: () {
var originIndex = widget.originIndex;
var teleplayIndex = widget.teleplayIndex;
if (teleplayIndex < originPlayList!.length - 1) {
widget.callback(originIndex, teleplayIndex + 1);
}
},
title: 'Next video',
),
];
},
};
setState(() { });
},
).catchError((error) {
// print(error);
setState(() {
_loading = false;
_error = true;
_errorMessage = error.message;
});
});
}
@override
void didUpdateWidget(covariant Player oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.teleplayIndex != oldWidget.teleplayIndex) {
_videoPlayerController?.dispose();
_initController();
}
}
```
#### Result
Abnormal black screen is stuck
#### Error info
```
Another exception was thrown: A PlayerNotifier was used after being disposed.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: A PlayerNotifier was used after being disposed.
Once you have called dispose() on a PlayerNotifier, it can no longer be used.
#0 ChangeNotifier.debugAssertNotDisposed. (package:flutter/src/foundation/change_notifier.dart:179:9)
#1 ChangeNotifier.debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:186:6)
#2 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:412:27)
#3 PlayerNotifier.hideStuff= (package:chewie/src/notifiers/player_notifier.dart:19:5)
#4 _CupertinoControlsState._startHideTimer.. (package:chewie/src/cupertino/cupertino_controls.dart:787:18)
#5 State.setState (package:flutter/src/widgets/framework.dart:1203:30)
#6 _CupertinoControlsState._startHideTimer. (package:chewie/src/cupertino/cupertino_controls.dart:786:7)
#7 Timer._createTimer.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with _initController and didUpdateWidget in the reported Player widget, then trace the Chewie PlayerNotifier and Cupertino controls locations shown in the stack trace. Reproduce switching the video source while full-screen and verify that the player does not reach a black screen or notify a disposed notifier.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100