From c2660b5e223c9c673795c1ec750b9a4d1377f1f9 Mon Sep 17 00:00:00 2001 From: WinUser01 Date: Thu, 10 Nov 2022 00:09:52 +0800 Subject: [PATCH] =?UTF-8?q?hyzp=5Fybqx-Commit179=EF=BC=9A=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=AE=9E=E7=8E=B0=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E7=9A=84=E6=9A=82=E5=81=9C=E3=80=81=E6=92=AD=E6=94=BE=E5=92=8C?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/widget/my_superplayer.dart | 41 +++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/widget/my_superplayer.dart b/lib/widget/my_superplayer.dart index d91f69c..b54417c 100644 --- a/lib/widget/my_superplayer.dart +++ b/lib/widget/my_superplayer.dart @@ -111,6 +111,7 @@ class _SuperPlayerPageState extends State with SuperPlayerListe await _playerController.setDataSource(widget.url, autoPlay: true).catchError((e) { print("setDataSource error: $e"); }); + playerRegionProvide.changePlayerState(bPlaying); } // Future init() async { @@ -641,25 +642,39 @@ class _SuperPlayerPageState extends State with SuperPlayerListe bool bPlaying = true; void playOrPause() { - //state : 1 播放状态,2 暂停状态 - // _playerController.getPlayState().then((state) { - // print('state = $state'); - // if (1 == state) { - // bPlaying = false; - // _playerController.pause(); - // } else { - // bPlaying = true; - // _playerController.resume(); - // } - // playerRegionProvide.changePlayerState(bPlaying); - // Storage.setString('bPlaying', bPlaying ? 'true' : 'false'); - // setState(() {}); + // playerRegionProvide.changePlayerState(bPlaying); + // + // if (bPlaying) { + // _playerController.start(); + // } else { + // _playerController.pause(); + // } + // + // setState(() { + // bPlaying = !bPlaying; // }); + + //state : 1 播放状态,2 暂停状态 + if (FijkState.started == _playerController.state) { + bPlaying = false; + _playerController.pause(); + } else { + bPlaying = true; + _playerController.start(); + } + playerRegionProvide.changePlayerState(bPlaying); + Storage.setString('bPlaying', bPlaying ? 'true' : 'false'); + setState(() {}); } void restartPlay(String url) async { _playState = 4; bPlaying = true; + + await _playerController.stop(); + await _playerController.reset(); + startPlay(); + // _playerController.resetPlayer(); // _playerController.resume();