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>
|
class _VideoViewerState extends State<VideoViewer>
|
||||||
with DisposableManagerMixin<VideoViewer> {
|
with DisposableManagerMixin<VideoViewer> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_getVideoUrl().then((url) {
|
_getVideoUrl().then((url) {
|
||||||
setState(() {
|
if (mounted) {
|
||||||
_initController(url);
|
setState(() {
|
||||||
});
|
_initController(url);
|
||||||
|
});
|
||||||
|
}
|
||||||
}).onError((e, stacktrace) {
|
}).onError((e, stacktrace) {
|
||||||
_log.shout("[initState] Failed while _getVideoUrl", e, stacktrace);
|
_log.shout("[initState] Failed while _getVideoUrl", e, stacktrace);
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
|
@ -75,6 +77,12 @@ class _VideoViewerState extends State<VideoViewer>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controllerValue?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
initDisposables() {
|
initDisposables() {
|
||||||
return [
|
return [
|
||||||
|
@ -100,15 +108,9 @@ class _VideoViewerState extends State<VideoViewer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
dispose() {
|
|
||||||
super.dispose();
|
|
||||||
_controller.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _initController(String url) async {
|
Future<void> _initController(String url) async {
|
||||||
try {
|
try {
|
||||||
_controller = VideoPlayerController.network(
|
_controllerValue = VideoPlayerController.network(
|
||||||
url,
|
url,
|
||||||
httpHeaders: {
|
httpHeaders: {
|
||||||
"Authorization": AuthUtil.fromAccount(widget.account).toHeaderValue(),
|
"Authorization": AuthUtil.fromAccount(widget.account).toHeaderValue(),
|
||||||
|
@ -293,9 +295,11 @@ class _VideoViewerState extends State<VideoViewer>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VideoPlayerController get _controller => _controllerValue!;
|
||||||
|
|
||||||
final _key = GlobalKey();
|
final _key = GlobalKey();
|
||||||
bool _isControllerInitialized = false;
|
bool _isControllerInitialized = false;
|
||||||
late VideoPlayerController _controller;
|
VideoPlayerController? _controllerValue;
|
||||||
var _isFinished = false;
|
var _isFinished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue