mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-23 18:46:53 +08:00
opt handle res
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -12,6 +12,7 @@ import 'package:PiliPlus/models/common/audio_normalization.dart';
|
||||
import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart';
|
||||
import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
|
||||
import 'package:PiliPlus/models/user/danmaku_rule.dart';
|
||||
import 'package:PiliPlus/models/video_shot/data.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_source.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/data_status.dart';
|
||||
@@ -510,7 +511,7 @@ class PlPlayerController {
|
||||
List<Segment>? segmentList,
|
||||
List<Segment>? viewPointList,
|
||||
bool? showVP,
|
||||
List? dmTrend,
|
||||
List<double>? dmTrend,
|
||||
bool autoplay = true,
|
||||
// 默认不循环
|
||||
PlaylistMode looping = PlaylistMode.none,
|
||||
@@ -536,7 +537,7 @@ class PlPlayerController {
|
||||
this.segmentList.value = segmentList ?? <Segment>[];
|
||||
this.viewPointList.value = viewPointList ?? <Segment>[];
|
||||
this.showVP.value = showVP ?? true;
|
||||
this.dmTrend.value = dmTrend ?? [];
|
||||
this.dmTrend.value = dmTrend ?? <double>[];
|
||||
_autoPlay = autoplay;
|
||||
_looping = looping;
|
||||
// 初始化视频倍速
|
||||
@@ -1600,7 +1601,7 @@ class PlPlayerController {
|
||||
if (res.data['code'] == 0) {
|
||||
videoShot = {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
'data': VideoShotData.fromJson(res.data['data']),
|
||||
};
|
||||
} else {
|
||||
videoShot = {'status': false};
|
||||
@@ -1611,7 +1612,7 @@ class PlPlayerController {
|
||||
_isQueryingVideoShot = false;
|
||||
}
|
||||
|
||||
late final RxList dmTrend = [].obs;
|
||||
late final RxList<double> dmTrend = <double>[].obs;
|
||||
late final RxBool showDmTreandChart = true.obs;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:PiliPlus/common/widgets/progress_bar/audio_video_progress_bar.da
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/segment_progress_bar.dart';
|
||||
import 'package:PiliPlus/models/common/super_resolution_type.dart';
|
||||
import 'package:PiliPlus/models/video_detail_res.dart';
|
||||
import 'package:PiliPlus/models/video_shot/data.dart';
|
||||
import 'package:PiliPlus/pages/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/pgc/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
||||
@@ -1772,7 +1773,7 @@ Widget buildDmChart(
|
||||
plPlayerController.dmTrend.length,
|
||||
(index) => FlSpot(
|
||||
index.toDouble(),
|
||||
plPlayerController.dmTrend[index].toDouble(),
|
||||
plPlayerController.dmTrend[index],
|
||||
),
|
||||
),
|
||||
isCurved: true,
|
||||
@@ -1793,98 +1794,84 @@ Widget buildDmChart(
|
||||
|
||||
Widget buildSeekPreviewWidget(PlPlayerController plPlayerController) {
|
||||
return Obx(() {
|
||||
if (plPlayerController.showPreview.value.not) {
|
||||
return SizedBox.shrink(
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
);
|
||||
}
|
||||
if (plPlayerController.videoShot == null) {
|
||||
if (!plPlayerController.showPreview.value ||
|
||||
plPlayerController.videoShot?['status'] != true) {
|
||||
plPlayerController.getVideoShot();
|
||||
return SizedBox.shrink(
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
);
|
||||
} else if (plPlayerController.videoShot!['status'] == false) {
|
||||
return SizedBox.shrink(
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
);
|
||||
}
|
||||
|
||||
VideoShotData data = plPlayerController.videoShot!['data'];
|
||||
|
||||
return LayoutBuilder(
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
builder: (context, constraints) {
|
||||
try {
|
||||
double scale = plPlayerController.isFullScreen.value &&
|
||||
plPlayerController.direction.value == 'horizontal'
|
||||
? 4
|
||||
: 2.5;
|
||||
// offset
|
||||
double left = (plPlayerController.previewDx.value - 48 * scale / 2)
|
||||
.clamp(8, constraints.maxWidth - 48 * scale - 8);
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
builder: (context, constraints) {
|
||||
try {
|
||||
double scale = plPlayerController.isFullScreen.value &&
|
||||
plPlayerController.direction.value == 'horizontal'
|
||||
? 4
|
||||
: 2.5;
|
||||
// offset
|
||||
double left = (plPlayerController.previewDx.value - 48 * scale / 2)
|
||||
.clamp(8, constraints.maxWidth - 48 * scale - 8);
|
||||
|
||||
// index
|
||||
// int index = plPlayerController.sliderPositionSeconds.value ~/ 5;
|
||||
int index = max(
|
||||
0,
|
||||
(List<int>.from(plPlayerController.videoShot!['data']['index'])
|
||||
.where((item) =>
|
||||
item <=
|
||||
plPlayerController.sliderPositionSeconds.value)
|
||||
.length -
|
||||
2));
|
||||
|
||||
// pageIndex
|
||||
int pageIndex = (index ~/ 100).clamp(
|
||||
// index
|
||||
// int index = plPlayerController.sliderPositionSeconds.value ~/ 5;
|
||||
int index = max(
|
||||
0,
|
||||
(plPlayerController.videoShot!['data']['image'] as List).length,
|
||||
);
|
||||
(data.index!
|
||||
.where((item) =>
|
||||
item <=
|
||||
plPlayerController.sliderPositionSeconds.value)
|
||||
.length -
|
||||
2));
|
||||
|
||||
// alignment
|
||||
double cal(m) {
|
||||
return -1 + 2 / 9 * m;
|
||||
}
|
||||
// pageIndex
|
||||
int pageIndex = (index ~/ 100).clamp(0, data.image!.length);
|
||||
|
||||
int align = index % 100;
|
||||
int x = align % 10;
|
||||
int y = align ~/ 10;
|
||||
double dx = cal(x);
|
||||
double dy = cal(y);
|
||||
Alignment alignment = Alignment(dx, dy);
|
||||
// alignment
|
||||
double cal(m) {
|
||||
return -1 + 2 / 9 * m;
|
||||
}
|
||||
|
||||
// url
|
||||
String parseUrl(String url) {
|
||||
return url.startsWith('//') ? 'https:$url' : url;
|
||||
}
|
||||
int align = index % 100;
|
||||
int x = align % 10;
|
||||
int y = align ~/ 10;
|
||||
double dx = cal(x);
|
||||
double dy = cal(y);
|
||||
Alignment alignment = Alignment(dx, dy);
|
||||
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: left),
|
||||
child: UnconstrainedBox(
|
||||
child: ClipRRect(
|
||||
borderRadius: scale == 2.5
|
||||
? const BorderRadius.all(Radius.circular(6))
|
||||
: StyleString.mdRadius,
|
||||
child: Align(
|
||||
widthFactor: 0.1,
|
||||
heightFactor: 0.1,
|
||||
alignment: alignment,
|
||||
child: CachedNetworkImage(
|
||||
fit: BoxFit.fill,
|
||||
width: 480 * scale,
|
||||
height: 270 * scale,
|
||||
imageUrl: parseUrl(plPlayerController.videoShot!['data']
|
||||
['image'][pageIndex]),
|
||||
),
|
||||
return Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.only(left: left),
|
||||
child: UnconstrainedBox(
|
||||
child: ClipRRect(
|
||||
borderRadius: scale == 2.5
|
||||
? const BorderRadius.all(Radius.circular(6))
|
||||
: StyleString.mdRadius,
|
||||
child: Align(
|
||||
widthFactor: 0.1,
|
||||
heightFactor: 0.1,
|
||||
alignment: alignment,
|
||||
child: CachedNetworkImage(
|
||||
fit: BoxFit.fill,
|
||||
width: 480 * scale,
|
||||
height: 270 * scale,
|
||||
imageUrl: data.image![pageIndex].http2https,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('seek preview: $e');
|
||||
return SizedBox.shrink(
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
);
|
||||
}
|
||||
});
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('seek preview: $e');
|
||||
return SizedBox.shrink(
|
||||
key: ValueKey(plPlayerController.previewDx.value),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user