mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
seek from ugc intro
Closes #1303 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -18,6 +18,7 @@ import 'package:PiliPlus/pages/video/introduction/ugc/widgets/season.dart';
|
|||||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/selectable_text.dart';
|
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/selectable_text.dart';
|
||||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||||
import 'package:PiliPlus/utils/date_utils.dart';
|
import 'package:PiliPlus/utils/date_utils.dart';
|
||||||
|
import 'package:PiliPlus/utils/duration_utils.dart';
|
||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
import 'package:PiliPlus/utils/feed_back.dart';
|
||||||
import 'package:PiliPlus/utils/id_utils.dart';
|
import 'package:PiliPlus/utils/id_utils.dart';
|
||||||
@@ -592,7 +593,7 @@ class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final RegExp urlRegExp = RegExp(
|
static final RegExp urlRegExp = RegExp(
|
||||||
'${Constants.urlRegex.pattern}|av\\d+|bv[a-z\\d]{10}',
|
Constants.urlRegex.pattern + r'|av\d+|bv[a-z\d]{10}|(?:\d+[::])?\d+[::]\d+',
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -607,11 +608,12 @@ class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
|||||||
switch (currentDesc.type) {
|
switch (currentDesc.type) {
|
||||||
case 1:
|
case 1:
|
||||||
final List<InlineSpan> spanChildren = <InlineSpan>[];
|
final List<InlineSpan> spanChildren = <InlineSpan>[];
|
||||||
(currentDesc.rawText as String).splitMapJoin(
|
currentDesc.rawText?.splitMapJoin(
|
||||||
urlRegExp,
|
urlRegExp,
|
||||||
onMatch: (Match match) {
|
onMatch: (Match match) {
|
||||||
String matchStr = match[0]!;
|
final matchStr = match[0]!;
|
||||||
if (matchStr.toLowerCase().startsWith('http')) {
|
final matchStrLowerCase = matchStr.toLowerCase();
|
||||||
|
if (matchStrLowerCase.startsWith('http')) {
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: matchStr,
|
text: matchStr,
|
||||||
@@ -626,7 +628,7 @@ class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (matchStr.startsWith('av')) {
|
} else if (matchStrLowerCase.startsWith('av')) {
|
||||||
try {
|
try {
|
||||||
int aid = int.parse(matchStr.substring(2));
|
int aid = int.parse(matchStr.substring(2));
|
||||||
IdUtils.av2bv(aid);
|
IdUtils.av2bv(aid);
|
||||||
@@ -641,7 +643,7 @@ class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
spanChildren.add(TextSpan(text: matchStr));
|
spanChildren.add(TextSpan(text: matchStr));
|
||||||
}
|
}
|
||||||
} else {
|
} else if (matchStrLowerCase.startsWith('bv')) {
|
||||||
try {
|
try {
|
||||||
IdUtils.bv2av(matchStr);
|
IdUtils.bv2av(matchStr);
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
@@ -655,6 +657,26 @@ class _UgcIntroPanelState extends State<UgcIntroPanel> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
spanChildren.add(TextSpan(text: matchStr));
|
spanChildren.add(TextSpan(text: matchStr));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
spanChildren.add(
|
||||||
|
TextSpan(
|
||||||
|
text: matchStr,
|
||||||
|
style: TextStyle(color: theme.colorScheme.primary),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
try {
|
||||||
|
Get.find<VideoDetailController>(
|
||||||
|
tag: widget.heroTag,
|
||||||
|
).plPlayerController.seekTo(
|
||||||
|
Duration(
|
||||||
|
seconds: DurationUtils.parseDuration(matchStr),
|
||||||
|
),
|
||||||
|
isSeek: false,
|
||||||
|
);
|
||||||
|
} catch (_) {}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,11 +17,12 @@ abstract class DurationUtils {
|
|||||||
: "${h.toString().padLeft(2, '0')}:${m.toString().padLeft(2, '0')}:$sms";
|
: "${h.toString().padLeft(2, '0')}:${m.toString().padLeft(2, '0')}:$sms";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static final _splitRegex = RegExp(r'[::]');
|
||||||
static int parseDuration(String? data) {
|
static int parseDuration(String? data) {
|
||||||
if (data == null || data.isEmpty) {
|
if (data == null || data.isEmpty) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
List<int> split = data.split(':').reversed.map(int.parse).toList();
|
List<int> split = data.split(_splitRegex).reversed.map(int.parse).toList();
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
duration += split[i] * pow(60, i).toInt();
|
duration += split[i] * pow(60, i).toInt();
|
||||||
|
|||||||
Reference in New Issue
Block a user