mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +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();
|
||||
}
|
||||
|
||||
void _initController(String url) {
|
||||
void _initController(String url) async {
|
||||
try {
|
||||
_controller = VideoPlayerController.network(
|
||||
url,
|
||||
httpHeaders: {
|
||||
"Authorization": Api.getAuthorizationHeaderValue(widget.account),
|
||||
},
|
||||
)..initialize().then((_) {
|
||||
);
|
||||
await _controller.initialize();
|
||||
widget.onLoaded?.call();
|
||||
setState(() {});
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
|
@ -97,11 +99,15 @@ class _VideoViewerState extends State<VideoViewer> {
|
|||
widget.onHeightChanged?.call(_key.currentContext!.size!.height);
|
||||
}
|
||||
});
|
||||
}).catchError((e, stacktrace) {
|
||||
_log.shout("[initState] Filed while initialize", e, stacktrace);
|
||||
});
|
||||
_controller.addListener(_onControllerChanged);
|
||||
_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) {
|
||||
|
|
Loading…
Reference in a new issue