feat: 继续播放、重新播放
This commit is contained in:
@ -37,6 +37,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// );
|
||||
StreamSubscription? _playerEventSubs;
|
||||
bool isPlay = false;
|
||||
PlayerStatus playerStatus = PlayerStatus.paused;
|
||||
bool isShowCover = true;
|
||||
double doubleOffset = 0;
|
||||
|
||||
@ -47,6 +48,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
_playerEventSubs = _meeduPlayerController!.onPlayerStatusChanged.listen(
|
||||
(PlayerStatus status) {
|
||||
videoDetailController.markHeartBeat();
|
||||
playerStatus = status;
|
||||
if (status == PlayerStatus.playing) {
|
||||
Wakelock.enable();
|
||||
isPlay = false;
|
||||
@ -58,10 +60,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
isPlay = true;
|
||||
setState(() {});
|
||||
Wakelock.disable();
|
||||
}
|
||||
// 播放完成停止 or 切换下一个
|
||||
if (status == PlayerStatus.completed) {
|
||||
_meeduPlayerController!.pause();
|
||||
// 播放完成停止 or 切换下一个
|
||||
if (status == PlayerStatus.completed) {}
|
||||
}
|
||||
},
|
||||
);
|
||||
@ -93,6 +93,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
}
|
||||
|
||||
void continuePlay() async {
|
||||
await _extendNestCtr.animateTo(0,
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
_meeduPlayerController!.play();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
videoDetailController.meeduPlayerController.dispose();
|
||||
@ -240,7 +246,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
];
|
||||
},
|
||||
pinnedHeaderSliverHeightBuilder: () {
|
||||
return isPlay
|
||||
return playerStatus != PlayerStatus.playing
|
||||
? MediaQuery.of(context).padding.top + 50
|
||||
: pinnedHeaderHeight;
|
||||
},
|
||||
@ -327,16 +333,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
scrolledUnderElevation: 0,
|
||||
centerTitle: true,
|
||||
title: TextButton(
|
||||
onPressed: () {
|
||||
_extendNestCtr.animateTo(0,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOut);
|
||||
},
|
||||
onPressed: () => continuePlay(),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
Icon(Icons.play_arrow_rounded),
|
||||
Text('继续播放')
|
||||
children: [
|
||||
const Icon(Icons.play_arrow_rounded),
|
||||
Text(
|
||||
playerStatus == PlayerStatus.paused
|
||||
? '继续播放'
|
||||
: playerStatus == PlayerStatus.completed
|
||||
? '重新播放'
|
||||
: '播放中',
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user