diff --git a/lib/view/video.dart b/lib/view/video.dart index 1991db1..ddff250 100644 --- a/lib/view/video.dart +++ b/lib/view/video.dart @@ -55,8 +55,8 @@ class _CustomVideoPlayerState extends State { }); } - void onKey(RawKeyEvent event){ - if(event is RawKeyUpEvent) return; + void onKey(RawKeyEvent event) { + if (event is RawKeyUpEvent) return; RawKeyEventDataAndroid e = event.data as RawKeyEventDataAndroid; switch (e.keyCode) { case 21: @@ -68,7 +68,7 @@ class _CustomVideoPlayerState extends State { _controller!.seekTo(Duration(milliseconds: pos + 30000)); break; case 62: - if(_controller!.value.isPlaying){ + if (_controller!.value.isPlaying) { _controller!.pause(); } else { _controller!.play(); @@ -80,7 +80,7 @@ class _CustomVideoPlayerState extends State { } void fijkOnKey(RawKeyEvent event) { - if(event is RawKeyUpEvent) return; + if (event is RawKeyUpEvent) return; switch (event.character) { case ' ': if (player?.state == FijkState.paused) { @@ -93,17 +93,17 @@ class _CustomVideoPlayerState extends State { switch ((event.data as RawKeyEventDataAndroid).keyCode) { case 22: // player!.pause().then((value) { - int pos = min(player!.value.duration.inMilliseconds, - player!.currentPos.inMilliseconds + 30000); - player!.seekTo(pos).then((value) { - if(_timer != null){ - _timer!.cancel(); - } - _timer = Timer(const Duration(milliseconds: 500), () { - player!.start(); - _timer = null; - }); + int pos = min(player!.value.duration.inMilliseconds, + player!.currentPos.inMilliseconds + 30000); + player!.seekTo(pos).then((value) { + if (_timer != null) { + _timer!.cancel(); + } + _timer = Timer(const Duration(milliseconds: 500), () { + player!.start(); + _timer = null; }); + }); // }); break; } @@ -114,22 +114,30 @@ class _CustomVideoPlayerState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - toolbarHeight: 35, - ), + // appBar: AppBar( + // toolbarHeight: 35, + // ), body: player == null - ? Center( - child: _controller!.value.isInitialized - ? AspectRatio( - aspectRatio: _controller!.value.aspectRatio, - child: RawKeyboardListener( - onKey: onKey, - autofocus: true, - focusNode: FocusNode(), - child: VideoPlayer(_controller!), - ), - ) - : Container(), + ? PopScope( + onPopInvoked: (val) { + if (!val) { + return; + } + _controller!.pause(); + }, + child: Center( + child: _controller!.value.isInitialized + ? AspectRatio( + aspectRatio: _controller!.value.aspectRatio, + child: RawKeyboardListener( + onKey: onKey, + autofocus: true, + focusNode: FocusNode(), + child: VideoPlayer(_controller!), + ), + ) + : Container(), + ), ) : Container( alignment: Alignment.center, @@ -146,17 +154,15 @@ class _CustomVideoPlayerState extends State { focusNode: FocusNode(), autofocus: true, child: PopScope( - onPopInvoked: (val){ - if(!val){ + onPopInvoked: (val) { + if (!val) { return; } this.player?.exitFullScreen(); }, - child: Stack( - children: [ + child: Stack(children: [ defaultFijkPanelBuilder( player, data, context, viewSize, texturePos), - ]), )); },