mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: progressbar: show viewpoints #28
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -114,6 +114,7 @@ class PlPlayerController {
|
||||
Timer? _timerForGettingVolume;
|
||||
Timer? timerForTrackingMouse;
|
||||
|
||||
final RxList<Segment> viewPointList = <Segment>[].obs;
|
||||
final RxList<Segment> segmentList = <Segment>[].obs;
|
||||
|
||||
// final Durations durations;
|
||||
@@ -430,6 +431,7 @@ class PlPlayerController {
|
||||
}) async {
|
||||
try {
|
||||
this.dataSource = dataSource;
|
||||
viewPointList.clear();
|
||||
this.segmentList.value = segmentList ?? <Segment>[];
|
||||
_autoPlay = autoplay;
|
||||
_looping = looping;
|
||||
@@ -1357,17 +1359,27 @@ class PlPlayerController {
|
||||
// if (!res["status"]) {
|
||||
// SmartDialog.showToast('查询字幕错误,${res["msg"]}');
|
||||
// }
|
||||
if (res["data"].length == 0) {
|
||||
return;
|
||||
|
||||
if (res["data"] is List && res["data"].isNotEmpty) {
|
||||
var result = await VideoHttp.vttSubtitles(res["data"]);
|
||||
if (result != null) {
|
||||
_vttSubtitles.value = result;
|
||||
}
|
||||
// if (_vttSubtitles.isEmpty) {
|
||||
// SmartDialog.showToast('字幕均加载失败');
|
||||
// }
|
||||
}
|
||||
var result = await VideoHttp.vttSubtitles(res["data"]);
|
||||
if (result != null) {
|
||||
_vttSubtitles.value = result;
|
||||
if (res["view_points"] is List && res["view_points"].isNotEmpty) {
|
||||
viewPointList.value = (res["view_points"] as List).map((item) {
|
||||
double start = (item['to'] / durationSeconds.value).clamp(0.0, 1.0);
|
||||
return Segment(
|
||||
start,
|
||||
start,
|
||||
Colors.black,
|
||||
item['content'],
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
// if (_vttSubtitles.isEmpty) {
|
||||
// SmartDialog.showToast('字幕均加载失败');
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// 设定字幕轨道
|
||||
|
||||
@@ -1014,7 +1014,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
BottomControl(
|
||||
controller: widget.controller,
|
||||
buildBottomControl: buildBottomControl(),
|
||||
segmentList: plPlayerController.segmentList,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1115,6 +1114,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
segmentColors: plPlayerController.segmentList,
|
||||
),
|
||||
),
|
||||
if (plPlayerController.viewPointList.isNotEmpty)
|
||||
CustomPaint(
|
||||
size: Size(double.infinity, 3.5),
|
||||
painter: SegmentProgressBar(
|
||||
progress: 1,
|
||||
segmentColors: plPlayerController.viewPointList,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// SlideTransition(
|
||||
|
||||
@@ -13,11 +13,9 @@ import '../../../common/widgets/audio_video_progress_bar.dart';
|
||||
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
final PlPlayerController? controller;
|
||||
final List<Widget>? buildBottomControl;
|
||||
final List<Segment>? segmentList;
|
||||
const BottomControl({
|
||||
this.controller,
|
||||
this.buildBottomControl,
|
||||
this.segmentList,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -98,12 +96,20 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
TextDirection.ltr);
|
||||
},
|
||||
),
|
||||
if (segmentList?.isNotEmpty == true)
|
||||
if (controller?.segmentList.isNotEmpty == true)
|
||||
CustomPaint(
|
||||
size: Size(double.infinity, 3.5),
|
||||
painter: SegmentProgressBar(
|
||||
progress: 1,
|
||||
segmentColors: segmentList!,
|
||||
segmentColors: controller!.segmentList,
|
||||
),
|
||||
),
|
||||
if (controller?.viewPointList.isNotEmpty == true)
|
||||
CustomPaint(
|
||||
size: Size(double.infinity, 3.5),
|
||||
painter: SegmentProgressBar(
|
||||
progress: 1,
|
||||
segmentColors: controller!.viewPointList,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user