mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 10:58:50 +01:00
Show error if failed loading video
This commit is contained in:
parent
2edc989a76
commit
2bdcaede9d
1 changed files with 24 additions and 18 deletions
|
@ -83,13 +83,15 @@ class _VideoViewerState extends State<VideoViewer> {
|
||||||
Wakelock.disable();
|
Wakelock.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _initController(String url) {
|
void _initController(String url) async {
|
||||||
|
try {
|
||||||
_controller = VideoPlayerController.network(
|
_controller = VideoPlayerController.network(
|
||||||
url,
|
url,
|
||||||
httpHeaders: {
|
httpHeaders: {
|
||||||
"Authorization": Api.getAuthorizationHeaderValue(widget.account),
|
"Authorization": Api.getAuthorizationHeaderValue(widget.account),
|
||||||
},
|
},
|
||||||
)..initialize().then((_) {
|
);
|
||||||
|
await _controller.initialize();
|
||||||
widget.onLoaded?.call();
|
widget.onLoaded?.call();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||||
|
@ -97,11 +99,15 @@ class _VideoViewerState extends State<VideoViewer> {
|
||||||
widget.onHeightChanged?.call(_key.currentContext!.size!.height);
|
widget.onHeightChanged?.call(_key.currentContext!.size!.height);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catchError((e, stacktrace) {
|
|
||||||
_log.shout("[initState] Filed while initialize", e, stacktrace);
|
|
||||||
});
|
|
||||||
_controller.addListener(_onControllerChanged);
|
_controller.addListener(_onControllerChanged);
|
||||||
_isControllerInitialized = true;
|
_isControllerInitialized = true;
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
_log.shout("[_initController] Failed while initialize", e, stackTrace);
|
||||||
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
|
content: Text(exception_util.toUserString(e)),
|
||||||
|
duration: k.snackBarDurationNormal,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildPlayer(BuildContext context) {
|
Widget _buildPlayer(BuildContext context) {
|
||||||
|
|
Loading…
Reference in a new issue