mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-29 22:00:16 +08:00
feat: more subtitle
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:PiliPlus/common/widgets/pair.dart';
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/segment_progress_bar.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/app/listener/v1.pbenum.dart'
|
||||
show PlaylistSource;
|
||||
import 'package:PiliPlus/grpc/dm.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -1178,24 +1179,52 @@ class VideoDetailController extends GetxController
|
||||
}
|
||||
|
||||
if (response.subtitle?.subtitles case final sub? when (sub.isNotEmpty)) {
|
||||
subtitles.value = sub;
|
||||
final idx = switch (Pref.subtitlePreferenceV2) {
|
||||
.off => 0,
|
||||
.on => 1,
|
||||
.withoutAi => sub.first.lan.startsWith('ai') ? 0 : 1,
|
||||
.auto =>
|
||||
!sub.first.lan.startsWith('ai') ||
|
||||
(PlatformUtils.isMobile &&
|
||||
(await FlutterVolumeController.getVolume() ?? 0.0) <=
|
||||
0.0)
|
||||
? 1
|
||||
: 0,
|
||||
};
|
||||
await setSubtitle(idx);
|
||||
_setSubtitle(sub);
|
||||
} else if (!Accounts.main.isLogin) {
|
||||
final res = await DmGrpc.dmView(aid, cid.value);
|
||||
if (res case Success(:final response)) {
|
||||
if (response.hasSubtitle() &&
|
||||
response.subtitle.subtitles.isNotEmpty) {
|
||||
_setSubtitle(
|
||||
response.subtitle.subtitles
|
||||
.map(
|
||||
(i) => Subtitle(
|
||||
lan: i.lan,
|
||||
lanDoc: i.lanDoc,
|
||||
subtitleUrl: i.subtitleUrl.replaceFirst(
|
||||
RegExp('^https?:'),
|
||||
'',
|
||||
),
|
||||
isAi: i.type == .AI,
|
||||
),
|
||||
)
|
||||
.toList()
|
||||
..sort(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
res.toast();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setSubtitle(List<Subtitle> sub) async {
|
||||
subtitles.value = sub;
|
||||
final idx = switch (Pref.subtitlePreferenceV2) {
|
||||
.off => 0,
|
||||
.on => 1,
|
||||
.withoutAi => sub.first.lan.startsWith('ai') ? 0 : 1,
|
||||
.auto =>
|
||||
!sub.first.lan.startsWith('ai') ||
|
||||
(PlatformUtils.isMobile &&
|
||||
(await FlutterVolumeController.getVolume() ?? 0.0) <= 0.0)
|
||||
? 1
|
||||
: 0,
|
||||
};
|
||||
await setSubtitle(idx);
|
||||
}
|
||||
|
||||
void updateMediaListHistory(int aid) {
|
||||
if (args['sortField'] != null) {
|
||||
VideoHttp.medialistHistory(
|
||||
|
||||
Reference in New Issue
Block a user