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();