hyzp_ybqx-Commit179:已经实现视频播放的暂停、播放和重新播放
This commit is contained in:
@@ -111,6 +111,7 @@ class _SuperPlayerPageState extends State<SuperPlayerPage> with SuperPlayerListe
|
|||||||
await _playerController.setDataSource(widget.url, autoPlay: true).catchError((e) {
|
await _playerController.setDataSource(widget.url, autoPlay: true).catchError((e) {
|
||||||
print("setDataSource error: $e");
|
print("setDataSource error: $e");
|
||||||
});
|
});
|
||||||
|
playerRegionProvide.changePlayerState(bPlaying);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> init() async {
|
// Future<void> init() async {
|
||||||
@@ -641,25 +642,39 @@ class _SuperPlayerPageState extends State<SuperPlayerPage> with SuperPlayerListe
|
|||||||
bool bPlaying = true;
|
bool bPlaying = true;
|
||||||
|
|
||||||
void playOrPause() {
|
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);
|
// playerRegionProvide.changePlayerState(bPlaying);
|
||||||
// Storage.setString('bPlaying', bPlaying ? 'true' : 'false');
|
//
|
||||||
// setState(() {});
|
// 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 {
|
void restartPlay(String url) async {
|
||||||
_playState = 4;
|
_playState = 4;
|
||||||
bPlaying = true;
|
bPlaying = true;
|
||||||
|
|
||||||
|
await _playerController.stop();
|
||||||
|
await _playerController.reset();
|
||||||
|
startPlay();
|
||||||
|
|
||||||
// _playerController.resetPlayer();
|
// _playerController.resetPlayer();
|
||||||
// _playerController.resume();
|
// _playerController.resume();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user