feat: 快进、快退、拖动时时间戳展示、关闭自动播放时处理、单p播放完成处理
This commit is contained in:
@ -50,6 +50,10 @@ class VideoDetailController extends GetxController
|
||||
Box user = GStrorage.user;
|
||||
Box localCache = GStrorage.localCache;
|
||||
PlPlayerController plPlayerController = PlPlayerController();
|
||||
// 是否开始自动播放 存在多p的情况下,第二p需要为true
|
||||
RxBool autoPlay = true.obs;
|
||||
// 视频资源是否有效
|
||||
RxBool isEffective = true.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -130,12 +134,17 @@ class VideoDetailController extends GetxController
|
||||
),
|
||||
// 硬解
|
||||
enableHA: true,
|
||||
autoplay: true,
|
||||
autoplay: autoPlay.value,
|
||||
seekTo: defaultST,
|
||||
duration: Duration(milliseconds: duration),
|
||||
);
|
||||
}
|
||||
|
||||
// 手动点击播放
|
||||
handlePlay() {
|
||||
plPlayerController.togglePlay();
|
||||
}
|
||||
|
||||
// 视频链接
|
||||
queryVideoUrl() async {
|
||||
var result = await VideoHttp.videoUrl(cid: cid, bvid: bvid);
|
||||
|
@ -55,7 +55,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
isPlay = true;
|
||||
setState(() {});
|
||||
// 播放完成停止 or 切换下一个
|
||||
if (status == PlayerStatus.completed) {}
|
||||
if (status == PlayerStatus.completed) {
|
||||
// 当只有1p或多p未打开自动播放时,播放完成还原进度条,展示控制栏
|
||||
plPlayerController!.seekTo(Duration.zero);
|
||||
plPlayerController!.onLockControl(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
@ -180,6 +184,38 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
/// 关闭自动播放时 手动播放
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: isShowCover &&
|
||||
videoDetailController
|
||||
.isEffective.value &&
|
||||
!videoDetailController.autoPlay.value,
|
||||
child: Positioned(
|
||||
right: 12,
|
||||
bottom: 6,
|
||||
child: TextButton.icon(
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStateProperty
|
||||
.resolveWith((states) {
|
||||
return Theme.of(context)
|
||||
.colorScheme
|
||||
.primaryContainer;
|
||||
}),
|
||||
),
|
||||
onPressed: () => videoDetailController
|
||||
.handlePlay(),
|
||||
icon: const Icon(
|
||||
Icons.play_circle_outline,
|
||||
size: 20,
|
||||
),
|
||||
label: const Text('Play'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user