merge main

This commit is contained in:
guozhigq
2024-01-20 13:44:32 +08:00
17 changed files with 557 additions and 171 deletions

1
.gitignore vendored
View File

@ -42,3 +42,4 @@ app.*.map.json
/android/app/debug /android/app/debug
/android/app/profile /android/app/profile
/android/app/release /android/app/release
/*/flutter/[Gg]enerated*[Pp]lugin*

View File

@ -20,7 +20,7 @@ class ContentContainer extends StatelessWidget {
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
return SingleChildScrollView( return SingleChildScrollView(
clipBehavior: childClipBehavior ?? Clip.hardEdge, clipBehavior: childClipBehavior ?? Clip.hardEdge,
physics: isScrollable ? null : NeverScrollableScrollPhysics(), physics: isScrollable ? null : const NeverScrollableScrollPhysics(),
child: ConstrainedBox( child: ConstrainedBox(
constraints: constraints.copyWith( constraints: constraints.copyWith(
minHeight: constraints.maxHeight, minHeight: constraints.maxHeight,
@ -34,7 +34,7 @@ class ContentContainer extends StatelessWidget {
child: contentWidget!, child: contentWidget!,
) )
else else
Spacer(), const Spacer(),
if (bottomWidget != null) bottomWidget!, if (bottomWidget != null) bottomWidget!,
], ],
), ),

View File

@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../http/search.dart'; import '../../http/search.dart';
import '../../http/user.dart'; import '../../http/user.dart';
import '../../http/video.dart';
import '../../utils/utils.dart'; import '../../utils/utils.dart';
import '../constants.dart'; import '../constants.dart';
import 'badge.dart'; import 'badge.dart';
@ -265,7 +266,6 @@ class VideoContent extends StatelessWidget {
height: 24, height: 24,
child: PopupMenuButton<String>( child: PopupMenuButton<String>(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
tooltip: '稍后再看',
icon: Icon( icon: Icon(
Icons.more_vert_outlined, Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
@ -280,10 +280,10 @@ class VideoContent extends StatelessWidget {
onTap: () async { onTap: () async {
var res = await UserHttp.toViewLater( var res = await UserHttp.toViewLater(
bvid: videoItem.bvid as String); bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg'] as String); SmartDialog.showToast(res['msg']);
}, },
value: 'pause', value: 'pause',
height: 35, height: 40,
child: const Row( child: const Row(
children: [ children: [
Icon(Icons.watch_later_outlined, size: 16), Icon(Icons.watch_later_outlined, size: 16),
@ -292,6 +292,59 @@ class VideoContent extends StatelessWidget {
], ],
), ),
), ),
const PopupMenuDivider(),
PopupMenuItem<String>(
onTap: () async {
SmartDialog.show(
useSystem: true,
animationType:
SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text(
'确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?'
'\n\n被拉黑的Up可以在隐私设置-黑名单管理中解除'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'点错了',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.outline),
),
),
TextButton(
onPressed: () async {
var res = await VideoHttp.relationMod(
mid: videoItem.owner.mid,
act: 5,
reSrc: 11,
);
SmartDialog.dismiss();
SmartDialog.showToast(
res['msg'] ?? '成功');
},
child: const Text('确认'),
)
],
);
},
);
},
value: 'pause',
height: 40,
child: Row(
children: [
const Icon(Icons.block, size: 16),
const SizedBox(width: 6),
Text('拉黑:${videoItem.owner.name}',
style: const TextStyle(fontSize: 13))
],
),
),
], ],
), ),
), ),

View File

@ -4,6 +4,7 @@ import 'package:get/get.dart';
import '../../http/dynamics.dart'; import '../../http/dynamics.dart';
import '../../http/search.dart'; import '../../http/search.dart';
import '../../http/user.dart'; import '../../http/user.dart';
import '../../http/video.dart';
import '../../models/common/search_type.dart'; import '../../models/common/search_type.dart';
import '../../utils/id_utils.dart'; import '../../utils/id_utils.dart';
import '../../utils/utils.dart'; import '../../utils/utils.dart';
@ -215,15 +216,10 @@ class VideoContent extends StatelessWidget {
), ),
if (videoItem.goto == 'av' && crossAxisCount == 1) ...[ if (videoItem.goto == 'av' && crossAxisCount == 1) ...[
const SizedBox(width: 10), const SizedBox(width: 10),
WatchLater( VideoPopupMenu(
size: 32, size: 32,
iconSize: 18, iconSize: 18,
callFn: () async { videoItem: videoItem,
int aid = videoItem.param;
var res =
await UserHttp.toViewLater(bvid: IdUtils.av2bv(aid));
SmartDialog.showToast(res['msg']);
},
), ),
], ],
], ],
@ -299,15 +295,10 @@ class VideoContent extends StatelessWidget {
const Spacer(), const Spacer(),
], ],
if (videoItem.goto == 'av' && crossAxisCount != 1) ...[ if (videoItem.goto == 'av' && crossAxisCount != 1) ...[
WatchLater( VideoPopupMenu(
size: 24, size: 24,
iconSize: 14, iconSize: 14,
callFn: () async { videoItem: videoItem,
int aid = videoItem.param;
var res =
await UserHttp.toViewLater(bvid: IdUtils.av2bv(aid));
SmartDialog.showToast(res['msg']);
},
), ),
] else ...[ ] else ...[
const SizedBox(height: 24) const SizedBox(height: 24)
@ -349,16 +340,16 @@ class VideoStat extends StatelessWidget {
} }
} }
class WatchLater extends StatelessWidget { class VideoPopupMenu extends StatelessWidget {
final double? size; final double? size;
final double? iconSize; final double? iconSize;
final Function? callFn; final dynamic videoItem;
const WatchLater({ const VideoPopupMenu({
Key? key, Key? key,
required this.size, required this.size,
required this.iconSize, required this.iconSize,
this.callFn, required this.videoItem,
}) : super(key: key); }) : super(key: key);
@override @override
@ -368,7 +359,6 @@ class WatchLater extends StatelessWidget {
height: size, height: size,
child: PopupMenuButton<String>( child: PopupMenuButton<String>(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
tooltip: '稍后再看',
icon: Icon( icon: Icon(
Icons.more_vert_outlined, Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,
@ -379,9 +369,13 @@ class WatchLater extends StatelessWidget {
onSelected: (String type) {}, onSelected: (String type) {},
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[ itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
PopupMenuItem<String>( PopupMenuItem<String>(
onTap: () => callFn!(), onTap: () async {
var res =
await UserHttp.toViewLater(bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg']);
},
value: 'pause', value: 'pause',
height: 35, height: 40,
child: const Row( child: const Row(
children: [ children: [
Icon(Icons.watch_later_outlined, size: 16), Icon(Icons.watch_later_outlined, size: 16),
@ -390,6 +384,55 @@ class WatchLater extends StatelessWidget {
], ],
), ),
), ),
const PopupMenuDivider(),
PopupMenuItem<String>(
onTap: () async {
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text(
'确定拉黑:${videoItem.owner.name}(${videoItem.owner.mid})?'
'\n\n被拉黑的Up可以在隐私设置-黑名单管理中解除'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'点错了',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await VideoHttp.relationMod(
mid: videoItem.owner.mid,
act: 5,
reSrc: 11,
);
SmartDialog.dismiss();
SmartDialog.showToast(res['msg'] ?? '成功');
},
child: const Text('确认'),
)
],
);
},
);
},
value: 'pause',
height: 40,
child: Row(
children: [
const Icon(Icons.block, size: 16),
const SizedBox(width: 6),
Text('拉黑:${videoItem.owner.name}',
style: const TextStyle(fontSize: 13))
],
),
),
], ],
), ),
); );

View File

@ -15,7 +15,7 @@ class HtmlHttp {
Match match = regex.firstMatch(response.data)!; Match match = regex.firstMatch(response.data)!;
String matchedString = match.group(0)!; String matchedString = match.group(0)!;
response = await Request().get( response = await Request().get(
'https:$matchedString' + '/', 'https:$matchedString/',
extra: {'ua': 'pc'}, extra: {'ua': 'pc'},
); );
} }

View File

@ -6,7 +6,7 @@ import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:dio/io.dart'; import 'package:dio/io.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart'; import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:dio_http2_adapter/dio_http2_adapter.dart'; // import 'package:dio_http2_adapter/dio_http2_adapter.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import '../utils/storage.dart'; import '../utils/storage.dart';
import '../utils/utils.dart'; import '../utils/utils.dart';

View File

@ -32,20 +32,27 @@ class VideoHttp {
Api.recommendListWeb, Api.recommendListWeb,
data: { data: {
'version': 1, 'version': 1,
'feed_version': 'V3', 'feed_version': 'V8',
'homepage_ver': 1,
'ps': ps, 'ps': ps,
'fresh_idx': freshIdx, 'fresh_idx': freshIdx,
'fresh_type': 999999 'brush': freshIdx,
'fresh_type': 4
}, },
); );
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
List<RecVideoItemModel> list = []; List<RecVideoItemModel> list = [];
List<int> blackMidsList =
setting.get(SettingBoxKey.blackMidsList, defaultValue: [-1]);
for (var i in res.data['data']['item']) { for (var i in res.data['data']['item']) {
list.add(RecVideoItemModel.fromJson(i)); //过滤掉live与ad以及拉黑用户
if (i['goto'] == 'av' && !blackMidsList.contains(i['owner']['mid'])) {
list.add(RecVideoItemModel.fromJson(i));
}
} }
return {'status': true, 'data': list}; return {'status': true, 'data': list};
} else { } else {
return {'status': false, 'data': [], 'msg': ''}; return {'status': false, 'data': [], 'msg': res.data['message']};
} }
} catch (err) { } catch (err) {
return {'status': false, 'data': [], 'msg': err.toString()}; return {'status': false, 'data': [], 'msg': err.toString()};
@ -133,6 +140,12 @@ class VideoHttp {
data['bvid'] = bvid; data['bvid'] = bvid;
} }
// 免登录查看1080p
if (userInfoCache.get('userInfoCache') == null &&
setting.get(SettingBoxKey.p1080, defaultValue: true)) {
data['try_look'] = 1;
}
Map params = await WbiSign().makSign({ Map params = await WbiSign().makSign({
...data, ...data,
'fourk': 1, 'fourk': 1,
@ -141,11 +154,6 @@ class VideoHttp {
'web_location': 1550101, 'web_location': 1550101,
}); });
// 免登录查看1080p
if (userInfoCache.get('userInfoCache') == null &&
setting.get(SettingBoxKey.p1080, defaultValue: true)) {
data['try_look'] = 1;
}
try { try {
var res = await Request().get(Api.videoUrl, data: params); var res = await Request().get(Api.videoUrl, data: params);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {

View File

@ -113,6 +113,13 @@ class MyApp extends StatelessWidget {
? darkColorScheme ? darkColorScheme
: lightColorScheme, : lightColorScheme,
useMaterial3: true, useMaterial3: true,
snackBarTheme: SnackBarThemeData(
actionTextColor: lightColorScheme.primary,
backgroundColor: lightColorScheme.secondaryContainer,
closeIconColor: lightColorScheme.secondary,
contentTextStyle: TextStyle(color: lightColorScheme.secondary),
elevation: 20,
),
pageTransitionsTheme: const PageTransitionsTheme( pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{ builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder( TargetPlatform.android: ZoomPageTransitionsBuilder(
@ -127,10 +134,11 @@ class MyApp extends StatelessWidget {
? lightColorScheme ? lightColorScheme
: darkColorScheme, : darkColorScheme,
useMaterial3: true, useMaterial3: true,
snackBarTheme: const SnackBarThemeData( snackBarTheme: SnackBarThemeData(
actionTextColor: Colors.white, actionTextColor: darkColorScheme.primary,
backgroundColor: Colors.black, backgroundColor: darkColorScheme.secondaryContainer,
contentTextStyle: TextStyle(color: Colors.white), closeIconColor: darkColorScheme.secondary,
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
elevation: 20, elevation: 20,
), ),
), ),

View File

@ -125,7 +125,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
child: DanmakuView( child: DanmakuView(
createdController: (DanmakuController e) async { createdController: (DanmakuController e) async {
widget.playerController.danmakuController = _controller = e; playerController.danmakuController = _controller = e;
}, },
option: DanmakuOption( option: DanmakuOption(
fontSize: 15 * fontSizeVal, fontSize: 15 * fontSizeVal,
@ -135,7 +135,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
hideScroll: blockTypes.contains(2), hideScroll: blockTypes.contains(2),
hideBottom: blockTypes.contains(4), hideBottom: blockTypes.contains(4),
duration: duration:
danmakuDurationVal / widget.playerController.playbackSpeed, danmakuDurationVal / playerController.playbackSpeed,
// initDuration / // initDuration /
// (danmakuSpeedVal * widget.playerController.playbackSpeed), // (danmakuSpeedVal * widget.playerController.playbackSpeed),
), ),

View File

@ -25,7 +25,7 @@ class MemberSeasonsItem extends StatelessWidget {
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
int cid = int cid =
await SearchHttp.ab2c(aid: seasonItem.aid, bvid: seasonItem.bvid); await SearchHttp.ab2c(aid: seasonItem.aid, bvid: seasonItem.bvid);
Get.toNamed('/video?bvid=${seasonItem.bvid}&cid=$cid', Get.toNamed('/video?bvid=${seasonItem.bvid}&cid=$cid',
arguments: {'videoItem': seasonItem, 'heroTag': heroTag}); arguments: {'videoItem': seasonItem, 'heroTag': heroTag});
}, },
@ -46,12 +46,13 @@ class MemberSeasonsItem extends StatelessWidget {
height: maxHeight, height: maxHeight,
), ),
), ),
if (seasonItem.duration != null) if (seasonItem.pubdate != null)
PBadge( PBadge(
bottom: 6, bottom: 6,
right: 6, right: 6,
type: 'gray', type: 'gray',
text: Utils.timeFormat(seasonItem.duration), text: Utils.CustomStamp_str(
timestamp: seasonItem.pubdate, date: 'YY-MM-DD'),
) )
], ],
); );
@ -78,7 +79,7 @@ class MemberSeasonsItem extends StatelessWidget {
const Spacer(), const Spacer(),
Text( Text(
Utils.CustomStamp_str( Utils.CustomStamp_str(
timestamp: seasonItem.pubdate, date: 'MM-DD'), timestamp: seasonItem.pubdate, date: 'YY-MM-DD'),
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 11,
color: Theme.of(context).colorScheme.outline, color: Theme.of(context).colorScheme.outline,

View File

@ -414,14 +414,18 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
), ),
), ),
const Spacer(), const Spacer(),
AnimatedOpacity( Obx(() => AnimatedOpacity(
opacity: loadingStatus ? 0 : 1, opacity: loadingStatus ||
duration: const Duration(milliseconds: 150), videoIntroController
child: SizedBox( .followStatus.isEmpty
height: 32, ? 0
child: Obx( : 1,
() => duration: const Duration(milliseconds: 50),
videoIntroController.followStatus.isNotEmpty child: SizedBox(
height: 32,
child: Obx(
() => videoIntroController
.followStatus.isNotEmpty
? TextButton( ? TextButton(
onPressed: videoIntroController onPressed: videoIntroController
.actionRelationMod, .actionRelationMod,
@ -453,9 +457,9 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
.actionRelationMod, .actionRelationMod,
child: const Text('关注'), child: const Text('关注'),
), ),
), ),
), ),
), )),
], ],
), ),
), ),

View File

@ -24,6 +24,7 @@ import 'package:pilipala/services/service_locator.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/plugin/pl_player/utils/fullscreen.dart'; import 'package:pilipala/plugin/pl_player/utils/fullscreen.dart';
import '../../../services/shutdown_timer_service.dart';
import 'widgets/header_control.dart'; import 'widgets/header_control.dart';
class VideoDetailPage extends StatefulWidget { class VideoDetailPage extends StatefulWidget {
@ -120,6 +121,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (autoExitFullcreen) { if (autoExitFullcreen) {
plPlayerController!.triggerFullScreen(status: false); plPlayerController!.triggerFullScreen(status: false);
} }
shutdownTimerService.handleWaitingFinished();
/// 顺序播放 列表循环 /// 顺序播放 列表循环
if (plPlayerController!.playRepeat != PlayRepeat.pause && if (plPlayerController!.playRepeat != PlayRepeat.pause &&
@ -187,6 +189,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
@override @override
void dispose() { void dispose() {
shutdownTimerService.handleWaitingFinished();
if (plPlayerController != null) { if (plPlayerController != null) {
plPlayerController!.removeStatusLister(playerListener); plPlayerController!.removeStatusLister(playerListener);
plPlayerController!.dispose(); plPlayerController!.dispose();
@ -213,6 +216,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoIntroController.isPaused = true; videoIntroController.isPaused = true;
plPlayerController!.removeStatusLister(playerListener); plPlayerController!.removeStatusLister(playerListener);
plPlayerController!.pause(); plPlayerController!.pause();
plPlayerController!.danmakuController?.pause();
plPlayerController!.danmakuController?.clear();
} }
super.didPushNext(); super.didPushNext();
} }
@ -388,107 +393,97 @@ class _VideoDetailPageState extends State<VideoDetailPage>
}, },
), ),
Obx( /// 关闭自动播放时 手动播放
() => Visibility( if (!videoDetailController
visible: videoDetailController .autoPlay.value) ...<Widget>[
.isShowCover.value, Obx(
child: Positioned( () => Visibility(
top: 0, visible: videoDetailController
left: 0, .isShowCover.value,
right: 0, child: Positioned(
child: GestureDetector( top: 0,
onTap: () { left: 0,
handlePlay(); right: 0,
}, child: GestureDetector(
child: NetworkImgLayer( onTap: () {
type: 'emote', handlePlay();
src: videoDetailController },
.videoItem['pic'], child: NetworkImgLayer(
width: maxWidth, type: 'emote',
height: maxHeight, src: videoDetailController
.videoItem['pic'],
width: maxWidth,
height: maxHeight,
),
), ),
), ),
), ),
), ),
), Obx(
() => Visibility(
/// 关闭自动播放时 手动播放 visible: videoDetailController
Obx( .isShowCover.value &&
() => Visibility( videoDetailController
visible: videoDetailController .isEffective.value,
.isShowCover.value && child: Stack(
videoDetailController children: [
.isEffective.value && Positioned(
!videoDetailController top: 0,
.autoPlay.value, left: 0,
child: Stack( right: 0,
children: [ child: AppBar(
Positioned( primary: false,
top: 0, foregroundColor:
left: 0, Colors.white,
right: 0, elevation: 0,
child: AppBar( scrolledUnderElevation: 0,
primary: false,
foregroundColor: Colors.white,
elevation: 0,
scrolledUnderElevation: 0,
backgroundColor:
Colors.transparent,
actions: [
IconButton(
tooltip: '稍后再看',
onPressed: () async {
var res = await UserHttp
.toViewLater(
bvid:
videoDetailController
.bvid);
SmartDialog.showToast(
res['msg']);
},
icon: const Icon(Icons
.history_outlined),
),
const SizedBox(width: 14)
],
),
),
Positioned(
right: 12,
bottom: 10,
child: TextButton.icon(
style: ButtonStyle(
side: MaterialStateProperty
.resolveWith((states) {
return BorderSide(
color: Theme.of(
context)
.colorScheme
.primary
.withOpacity(0.5),
width: 1);
}),
backgroundColor: backgroundColor:
MaterialStateProperty Colors.transparent,
.resolveWith( actions: [
(states) { IconButton(
return Theme.of(context) tooltip: '稍后再看',
.colorScheme onPressed: () async {
.background var res = await UserHttp
.withOpacity(0.6); .toViewLater(
}), bvid:
videoDetailController
.bvid);
SmartDialog.showToast(
res['msg']);
},
icon: const Icon(Icons
.history_outlined),
),
const SizedBox(width: 14)
],
), ),
onPressed: () => handlePlay(),
icon: const Icon(
Icons.play_circle_outline,
size: 20,
),
label: const Text('轻触封面播放'),
), ),
), Positioned(
], right: 12,
)), bottom: 10,
), child: TextButton.icon(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty
.resolveWith(
(states) {
return Colors.white
.withOpacity(0.8);
}),
),
onPressed: () =>
handlePlay(),
icon: const Icon(
Icons.play_circle_outline,
size: 20,
),
label: const Text('轻触封面播放'),
),
),
],
)),
),
]
], ],
); );
}, },

View File

@ -17,6 +17,7 @@ import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart'; import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/http/danmaku.dart'; import 'package:pilipala/http/danmaku.dart';
import 'package:pilipala/services/shutdown_timer_service.dart';
class HeaderControl extends StatefulWidget implements PreferredSizeWidget { class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
const HeaderControl({ const HeaderControl({
@ -39,14 +40,13 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
class _HeaderControlState extends State<HeaderControl> { class _HeaderControlState extends State<HeaderControl> {
late PlayUrlModel videoInfo; late PlayUrlModel videoInfo;
List<PlaySpeed> playSpeed = PlaySpeed.values; List<PlaySpeed> playSpeed = PlaySpeed.values;
TextStyle subTitleStyle = const TextStyle(fontSize: 12); static const TextStyle subTitleStyle = TextStyle(fontSize: 12);
TextStyle titleStyle = const TextStyle(fontSize: 14); static const TextStyle titleStyle = TextStyle(fontSize: 14);
Size get preferredSize => const Size(double.infinity, kToolbarHeight); Size get preferredSize => const Size(double.infinity, kToolbarHeight);
final Box<dynamic> localCache = GStrorage.localCache; final Box<dynamic> localCache = GStrorage.localCache;
final Box<dynamic> videoStorage = GStrorage.video; final Box<dynamic> videoStorage = GStrorage.video;
late List<double> speedsList; late List<double> speedsList;
double buttonSpace = 8; double buttonSpace = 8;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -63,7 +63,7 @@ class _HeaderControlState extends State<HeaderControl> {
builder: (_) { builder: (_) {
return Container( return Container(
width: double.infinity, width: double.infinity,
height: 440, height: 460,
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
@ -125,13 +125,20 @@ class _HeaderControlState extends State<HeaderControl> {
}, },
dense: true, dense: true,
leading: const Icon(Icons.watch_later_outlined, size: 20), leading: const Icon(Icons.watch_later_outlined, size: 20),
title: Text('添加至「稍后再看」', style: titleStyle), title: const Text('添加至「稍后再看」', style: titleStyle),
),
ListTile(
onTap: () => {Get.back(), scheduleExit()},
dense: true,
leading:
const Icon(Icons.hourglass_top_outlined, size: 20),
title: const Text('定时关闭(测试)', style: titleStyle),
), ),
ListTile( ListTile(
onTap: () => {Get.back(), showSetVideoQa()}, onTap: () => {Get.back(), showSetVideoQa()},
dense: true, dense: true,
leading: const Icon(Icons.play_circle_outline, size: 20), leading: const Icon(Icons.play_circle_outline, size: 20),
title: Text('选择画质', style: titleStyle), title: const Text('选择画质', style: titleStyle),
subtitle: Text( subtitle: Text(
'当前画质 ${widget.videoDetailCtr!.currentVideoQa.description}', '当前画质 ${widget.videoDetailCtr!.currentVideoQa.description}',
style: subTitleStyle), style: subTitleStyle),
@ -141,7 +148,7 @@ class _HeaderControlState extends State<HeaderControl> {
onTap: () => {Get.back(), showSetAudioQa()}, onTap: () => {Get.back(), showSetAudioQa()},
dense: true, dense: true,
leading: const Icon(Icons.album_outlined, size: 20), leading: const Icon(Icons.album_outlined, size: 20),
title: Text('选择音质', style: titleStyle), title: const Text('选择音质', style: titleStyle),
subtitle: Text( subtitle: Text(
'当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}', '当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}',
style: subTitleStyle), style: subTitleStyle),
@ -150,7 +157,7 @@ class _HeaderControlState extends State<HeaderControl> {
onTap: () => {Get.back(), showSetDecodeFormats()}, onTap: () => {Get.back(), showSetDecodeFormats()},
dense: true, dense: true,
leading: const Icon(Icons.av_timer_outlined, size: 20), leading: const Icon(Icons.av_timer_outlined, size: 20),
title: Text('解码格式', style: titleStyle), title: const Text('解码格式', style: titleStyle),
subtitle: Text( subtitle: Text(
'当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats.description}', '当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats.description}',
style: subTitleStyle), style: subTitleStyle),
@ -159,7 +166,7 @@ class _HeaderControlState extends State<HeaderControl> {
onTap: () => {Get.back(), showSetRepeat()}, onTap: () => {Get.back(), showSetRepeat()},
dense: true, dense: true,
leading: const Icon(Icons.repeat, size: 20), leading: const Icon(Icons.repeat, size: 20),
title: Text('播放顺序', style: titleStyle), title: const Text('播放顺序', style: titleStyle),
subtitle: Text(widget.controller!.playRepeat.description, subtitle: Text(widget.controller!.playRepeat.description,
style: subTitleStyle), style: subTitleStyle),
), ),
@ -167,7 +174,7 @@ class _HeaderControlState extends State<HeaderControl> {
onTap: () => {Get.back(), showSetDanmaku()}, onTap: () => {Get.back(), showSetDanmaku()},
dense: true, dense: true,
leading: const Icon(Icons.subtitles_outlined, size: 20), leading: const Icon(Icons.subtitles_outlined, size: 20),
title: Text('弹幕设置', style: titleStyle), title: const Text('弹幕设置', style: titleStyle),
), ),
], ],
), ),
@ -263,6 +270,133 @@ class _HeaderControlState extends State<HeaderControl> {
); );
} }
/// 定时关闭
void scheduleExit() async {
const List<int> scheduleTimeChoices = [
-1,
15,
30,
60,
];
showModalBottomSheet(
context: context,
elevation: 0,
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Container(
width: double.infinity,
height: 500,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: const BorderRadius.all(Radius.circular(12)),
),
margin: const EdgeInsets.all(12),
padding: const EdgeInsets.only(left: 14, right: 14),
child: SingleChildScrollView(
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 0, horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 30),
const Center(child: Text('定时关闭', style: titleStyle)),
const SizedBox(height: 10),
for (final int choice in scheduleTimeChoices) ...<Widget>[
ListTile(
onTap: () {
shutdownTimerService.scheduledExitInMinutes =
choice;
shutdownTimerService.startShutdownTimer();
Get.back();
},
contentPadding: const EdgeInsets.only(),
dense: true,
title: Text(choice == -1 ? "禁用" : "$choice分钟后"),
trailing: shutdownTimerService
.scheduledExitInMinutes ==
choice
? Icon(
Icons.done,
color: Theme.of(context).colorScheme.primary,
)
: const SizedBox(),
)
],
const SizedBox(height: 6),
const Center(
child: SizedBox(
width: 100,
child: Divider(height: 1),
)),
const SizedBox(height: 10),
ListTile(
onTap: () {
shutdownTimerService.waitForPlayingCompleted =
!shutdownTimerService.waitForPlayingCompleted;
setState(() {});
},
dense: true,
contentPadding: const EdgeInsets.only(),
title:
const Text("额外等待视频播放完毕", style: titleStyle),
trailing: Switch(
// thumb color (round icon)
activeColor: Theme.of(context).colorScheme.primary,
activeTrackColor:
Theme.of(context).colorScheme.primaryContainer,
inactiveThumbColor:
Theme.of(context).colorScheme.primaryContainer,
inactiveTrackColor:
Theme.of(context).colorScheme.background,
splashRadius: 10.0,
// boolean variable value
value: shutdownTimerService.waitForPlayingCompleted,
// changes the state of the switch
onChanged: (value) => setState(() =>
shutdownTimerService.waitForPlayingCompleted =
value),
),
),
const SizedBox(height: 10),
Row(
children: <Widget>[
const Text('倒计时结束:', style: titleStyle),
const Spacer(),
ActionRowLineItem(
onTap: () {
shutdownTimerService.exitApp = false;
setState(() {});
// Get.back();
},
text: " 暂停视频 ",
selectStatus: !shutdownTimerService.exitApp,
),
const Spacer(),
// const SizedBox(width: 10),
ActionRowLineItem(
onTap: () {
shutdownTimerService.exitApp = true;
setState(() {});
// Get.back();
},
text: " 退出APP ",
selectStatus: shutdownTimerService.exitApp,
)
],
),
]),
),
),
);
});
},
);
}
/// 选择倍速 /// 选择倍速
void showSetSpeedSheet() { void showSetSpeedSheet() {
final double currentSpeed = widget.controller!.playbackSpeed; final double currentSpeed = widget.controller!.playbackSpeed;
@ -367,7 +501,7 @@ class _HeaderControlState extends State<HeaderControl> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text('选择画质', style: titleStyle), const Text('选择画质', style: titleStyle),
SizedBox(width: buttonSpace), SizedBox(width: buttonSpace),
Icon( Icon(
Icons.info_outline, Icons.info_outline,
@ -448,7 +582,7 @@ class _HeaderControlState extends State<HeaderControl> {
margin: const EdgeInsets.all(12), margin: const EdgeInsets.all(12),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
SizedBox( const SizedBox(
height: 45, height: 45,
child: Center(child: Text('选择音质', style: titleStyle))), child: Center(child: Text('选择音质', style: titleStyle))),
Expanded( Expanded(
@ -614,7 +748,7 @@ class _HeaderControlState extends State<HeaderControl> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( const SizedBox(
height: 45, height: 45,
child: Center(child: Text('弹幕设置', style: titleStyle)), child: Center(child: Text('弹幕设置', style: titleStyle)),
), ),

View File

@ -210,11 +210,11 @@ class _WhisperPageState extends State<WhisperPage> {
); );
} else { } else {
// 请求错误 // 请求错误
return SizedBox(); return const SizedBox();
} }
} else { } else {
// 骨架屏 // 骨架屏
return SizedBox(); return const SizedBox();
} }
}, },
) )

View File

@ -289,9 +289,8 @@ class PlPlayerController {
_longPressSpeed.value = videoStorage _longPressSpeed.value = videoStorage
.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 2.0); .get(VideoBoxKey.longPressSpeedDefault, defaultValue: 2.0);
} }
final List<double> speedsListTemp = videoStorage speedsList = List<double>.from(videoStorage
.get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]); .get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]));
speedsList = List<double>.from(speedsListTemp);
for (final PlaySpeed i in PlaySpeed.values) { for (final PlaySpeed i in PlaySpeed.values) {
speedsList.add(i.value); speedsList.add(i.value);
} }

View File

@ -0,0 +1,140 @@
// 定时关闭服务
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import '../plugin/pl_player/controller.dart';
class ShutdownTimerService {
static final ShutdownTimerService _instance =
ShutdownTimerService._internal();
Timer? _shutdownTimer;
Timer? _autoCloseDialogTimer;
//定时退出
int scheduledExitInMinutes = -1;
bool exitApp = false;
bool waitForPlayingCompleted = false;
bool isWaiting = false;
factory ShutdownTimerService() => _instance;
ShutdownTimerService._internal();
void startShutdownTimer() {
cancelShutdownTimer(); // Cancel any previous timer
if (scheduledExitInMinutes == -1) {
//使用toast提示用户已取消
SmartDialog.showToast("取消定时关闭");
return;
}
SmartDialog.showToast("设置 $scheduledExitInMinutes 分钟后定时关闭");
_shutdownTimer = Timer(Duration(minutes: scheduledExitInMinutes),
() => _shutdownDecider());
}
void _showTimeUpButPauseDialog() {
SmartDialog.show(
builder: (BuildContext dialogContext) {
return AlertDialog(
title: const Text('定时关闭'),
content: const Text('时间到啦!'),
actions: <Widget>[
TextButton(
child: const Text('确认'),
onPressed: () {
cancelShutdownTimer();
SmartDialog.dismiss();
},
),
],
);
},
);
}
void _showShutdownDialog() {
SmartDialog.show(
builder: (BuildContext dialogContext) {
// Start the 10-second timer to auto close the dialog
_autoCloseDialogTimer?.cancel();
_autoCloseDialogTimer = Timer(const Duration(seconds: 10), () {
SmartDialog.dismiss();// Close the dialog
_executeShutdown();
});
return AlertDialog(
title: const Text('定时关闭'),
content: const Text('将在10秒后执行是否需要取消'),
actions: <Widget>[
TextButton(
child: const Text('取消关闭'),
onPressed: () {
_autoCloseDialogTimer?.cancel(); // Cancel the auto-close timer
cancelShutdownTimer(); // Cancel the shutdown timer
SmartDialog.dismiss(); // Close the dialog
},
),
],
);
},
).then((_) {
// Cleanup when the dialog is dismissed
_autoCloseDialogTimer?.cancel();
});
}
void _shutdownDecider() {
if (exitApp && !waitForPlayingCompleted) {
_showShutdownDialog();
return;
}
PlPlayerController plPlayerController = PlPlayerController.getInstance();
if (!exitApp && !waitForPlayingCompleted) {
if (!plPlayerController.playerStatus.playing) {
//仅提示用户
_showTimeUpButPauseDialog();
} else {
_showShutdownDialog();
}
return;
}
//waitForPlayingCompleted
if (!plPlayerController.playerStatus.playing) {
_showShutdownDialog();
return;
}
SmartDialog.showToast("定时关闭时间已到,等待当前视频播放完成");
//监听播放完成
//该方法依赖耦合实现,不够优雅
isWaiting = true;
}
void handleWaitingFinished(){
if(isWaiting){
_showShutdownDialog();
isWaiting = false;
}
}
void _executeShutdown() {
if (exitApp) {
//退出app
exit(0);
} else {
//暂停播放
PlPlayerController plPlayerController = PlPlayerController.getInstance();
if (plPlayerController.playerStatus.playing) {
plPlayerController.pause();
waitForPlayingCompleted = true;
SmartDialog.showToast("已暂停播放");
} else {
SmartDialog.showToast("当前未播放");
}
}
}
void cancelShutdownTimer() {
isWaiting = false;
_shutdownTimer?.cancel();
}
}
final shutdownTimerService = ShutdownTimerService();

View File

@ -80,7 +80,7 @@ class WbiSign {
String getMixinKey(String orig) { String getMixinKey(String orig) {
String temp = ''; String temp = '';
for (int i = 0; i < mixinKeyEncTab.length; i++) { for (int i = 0; i < mixinKeyEncTab.length; i++) {
temp += orig.split('')[mixinKeyEncTab[i] as int]; temp += orig.split('')[mixinKeyEncTab[i]];
} }
return temp.substring(0, 32); return temp.substring(0, 32);
} }