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