mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +01:00
Fix used before init in video viewer
This commit is contained in:
parent
bc3c480223
commit
6a29f8966c
1 changed files with 16 additions and 12 deletions
|
@ -59,12 +59,14 @@ class VideoViewer extends StatefulWidget {
|
|||
class _VideoViewerState extends State<VideoViewer>
|
||||
with DisposableManagerMixin<VideoViewer> {
|
||||
@override
|
||||
initState() {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_getVideoUrl().then((url) {
|
||||
setState(() {
|
||||
_initController(url);
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_initController(url);
|
||||
});
|
||||
}
|
||||
}).onError((e, stacktrace) {
|
||||
_log.shout("[initState] Failed while _getVideoUrl", e, stacktrace);
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
|
@ -75,6 +77,12 @@ class _VideoViewerState extends State<VideoViewer>
|
|||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controllerValue?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
initDisposables() {
|
||||
return [
|
||||
|
@ -100,15 +108,9 @@ class _VideoViewerState extends State<VideoViewer>
|
|||
);
|
||||
}
|
||||
|
||||
@override
|
||||
dispose() {
|
||||
super.dispose();
|
||||
_controller.dispose();
|
||||
}
|
||||
|
||||
Future<void> _initController(String url) async {
|
||||
try {
|
||||
_controller = VideoPlayerController.network(
|
||||
_controllerValue = VideoPlayerController.network(
|
||||
url,
|
||||
httpHeaders: {
|
||||
"Authorization": AuthUtil.fromAccount(widget.account).toHeaderValue(),
|
||||
|
@ -293,9 +295,11 @@ class _VideoViewerState extends State<VideoViewer>
|
|||
}
|
||||
}
|
||||
|
||||
VideoPlayerController get _controller => _controllerValue!;
|
||||
|
||||
final _key = GlobalKey();
|
||||
bool _isControllerInitialized = false;
|
||||
late VideoPlayerController _controller;
|
||||
VideoPlayerController? _controllerValue;
|
||||
var _isFinished = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue