Compare commits
6 Commits
feature-ba
...
feature-hi
Author | SHA1 | Date | |
---|---|---|---|
99e6abdad9 | |||
3ece2bb173 | |||
06fb3e8d2f | |||
504be6fbda | |||
df4539a035 | |||
a3e1fd4e91 |
@ -38,6 +38,10 @@ class VideoCardH extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final int aid = videoItem.aid;
|
||||
final String bvid = videoItem.bvid;
|
||||
String type = 'video';
|
||||
try {
|
||||
type = videoItem.type;
|
||||
} catch (_) {}
|
||||
final String heroTag = Utils.makeHeroTag(aid);
|
||||
return GestureDetector(
|
||||
onLongPress: () {
|
||||
@ -53,6 +57,10 @@ class VideoCardH extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
try {
|
||||
if (type == 'ketang') {
|
||||
SmartDialog.showToast('课堂视频暂不支持播放');
|
||||
return;
|
||||
}
|
||||
final int cid =
|
||||
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
Get.toNamed('/video?bvid=$bvid&cid=$cid',
|
||||
@ -95,12 +103,20 @@ class VideoCardH extends StatelessWidget {
|
||||
height: maxHeight,
|
||||
),
|
||||
),
|
||||
PBadge(
|
||||
text: Utils.timeFormat(videoItem.duration!),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
),
|
||||
if (videoItem.duration != 0)
|
||||
PBadge(
|
||||
text: Utils.timeFormat(videoItem.duration!),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
),
|
||||
if (type != 'video')
|
||||
PBadge(
|
||||
text: type,
|
||||
left: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'primary',
|
||||
),
|
||||
// if (videoItem.rcmdReason != null &&
|
||||
// videoItem.rcmdReason.content != '')
|
||||
// pBadge(videoItem.rcmdReason.content, context,
|
||||
|
@ -85,7 +85,9 @@ class SearchVideoItemModel {
|
||||
// title = json['title'].replaceAll(RegExp(r'<.*?>'), '');
|
||||
title = Em.regTitle(json['title']);
|
||||
description = json['description'];
|
||||
pic = 'https:${json['pic']}';
|
||||
pic = json['pic'] != null && json['pic'].startsWith('//')
|
||||
? 'https:${json['pic']}'
|
||||
: json['pic'] ?? '';
|
||||
videoReview = json['video_review'];
|
||||
pubdate = json['pubdate'];
|
||||
senddate = json['senddate'];
|
||||
|
@ -201,7 +201,6 @@ class _AboutPageState extends State<AboutPage> {
|
||||
var cleanStatus = await CacheManage().clearCacheAll();
|
||||
if (cleanStatus) {
|
||||
getCacheSize();
|
||||
SmartDialog.showToast('清除成功');
|
||||
}
|
||||
},
|
||||
title: const Text('清除缓存'),
|
||||
@ -254,12 +253,16 @@ class AboutController extends GetxController {
|
||||
// 获取远程版本
|
||||
Future getRemoteApp() async {
|
||||
var result = await Request().get(Api.latestApp, extra: {'ua': 'pc'});
|
||||
isLoading.value = false;
|
||||
if (result.data == null || result.data.isEmpty) {
|
||||
SmartDialog.showToast('获取远程版本失败,请检查网络');
|
||||
return;
|
||||
}
|
||||
data = LatestDataModel.fromJson(result.data);
|
||||
remoteAppInfo = data;
|
||||
remoteVersion.value = data.tagName!;
|
||||
isUpdate.value =
|
||||
Utils.needUpdate(currentVersion.value, remoteVersion.value);
|
||||
isLoading.value = false;
|
||||
}
|
||||
|
||||
// 跳转下载/本地更新
|
||||
@ -277,7 +280,7 @@ class AboutController extends GetxController {
|
||||
|
||||
githubRelease() {
|
||||
launchUrl(
|
||||
Uri.parse('https://github.com/guozhigq/pilipala/release'),
|
||||
Uri.parse('https://github.com/guozhigq/pilipala/releases'),
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ class BottomControl extends StatefulWidget implements PreferredSizeWidget {
|
||||
|
||||
class _BottomControlState extends State<BottomControl> {
|
||||
late PlayUrlModel videoInfo;
|
||||
List<PlaySpeed> playSpeed = PlaySpeed.values;
|
||||
TextStyle subTitleStyle = const TextStyle(fontSize: 12);
|
||||
TextStyle titleStyle = const TextStyle(fontSize: 14);
|
||||
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
||||
|
@ -173,6 +173,12 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
setKey: SettingBoxKey.enableAi,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '相关视频推荐',
|
||||
subTitle: '视频详情页推荐相关视频',
|
||||
setKey: SettingBoxKey.enableRelatedVideo,
|
||||
defaultVal: true,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('评论展示', style: titleStyle),
|
||||
|
@ -17,6 +17,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
Box videoStorage = GStrorage.video;
|
||||
Box settingStorage = GStrorage.setting;
|
||||
late double playSpeedDefault;
|
||||
late List<double> playSpeedSystem;
|
||||
late double longPressSpeedDefault;
|
||||
late List customSpeedsList;
|
||||
late bool enableAutoLongPressSpeed;
|
||||
@ -53,6 +54,9 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 系统预设倍速
|
||||
playSpeedSystem =
|
||||
videoStorage.get(VideoBoxKey.playSpeedSystem, defaultValue: playSpeed);
|
||||
// 默认倍速
|
||||
playSpeedDefault =
|
||||
videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
|
||||
@ -64,6 +68,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
videoStorage.get(VideoBoxKey.customSpeedsList, defaultValue: []);
|
||||
enableAutoLongPressSpeed = settingStorage
|
||||
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
||||
// 开启动态长按倍速时不展示
|
||||
if (enableAutoLongPressSpeed) {
|
||||
Map newItem = sheetMenu[1];
|
||||
newItem['show'] = false;
|
||||
@ -123,7 +128,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
}
|
||||
|
||||
// 设定倍速弹窗
|
||||
void showBottomSheet(type, i) {
|
||||
void showBottomSheet(String type, int i) {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
@ -159,18 +164,11 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
}
|
||||
|
||||
//
|
||||
void menuAction(type, index, id) async {
|
||||
void menuAction(type, int index, id) async {
|
||||
double chooseSpeed = 1.0;
|
||||
if (type == 'system' && id == -1) {
|
||||
SmartDialog.showToast('系统预设倍速不支持删除');
|
||||
return;
|
||||
}
|
||||
// 获取当前选中的倍速值
|
||||
if (type == 'system') {
|
||||
chooseSpeed = PlaySpeed.values[index].value;
|
||||
} else {
|
||||
chooseSpeed = customSpeedsList[index];
|
||||
}
|
||||
chooseSpeed =
|
||||
type == 'system' ? playSpeedSystem[index] : customSpeedsList[index];
|
||||
// 设置
|
||||
if (id == 1) {
|
||||
// 设置默认倍速
|
||||
@ -182,17 +180,22 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
videoStorage.put(
|
||||
VideoBoxKey.longPressSpeedDefault, longPressSpeedDefault);
|
||||
} else if (id == -1) {
|
||||
if (customSpeedsList[index] == playSpeedDefault) {
|
||||
playSpeedDefault = 1.0;
|
||||
videoStorage.put(VideoBoxKey.playSpeedDefault, playSpeedDefault);
|
||||
late List speedsList =
|
||||
type == 'system' ? playSpeedSystem : customSpeedsList;
|
||||
if (speedsList[index] == playSpeedDefault) {
|
||||
SmartDialog.showToast('默认倍速不可删除');
|
||||
}
|
||||
if (customSpeedsList[index] == longPressSpeedDefault) {
|
||||
if (speedsList[index] == longPressSpeedDefault) {
|
||||
longPressSpeedDefault = 2.0;
|
||||
videoStorage.put(
|
||||
VideoBoxKey.longPressSpeedDefault, longPressSpeedDefault);
|
||||
}
|
||||
customSpeedsList.removeAt(index);
|
||||
await videoStorage.put(VideoBoxKey.customSpeedsList, customSpeedsList);
|
||||
speedsList.removeAt(index);
|
||||
await videoStorage.put(
|
||||
type == 'system'
|
||||
? VideoBoxKey.playSpeedSystem
|
||||
: VideoBoxKey.customSpeedsList,
|
||||
speedsList);
|
||||
}
|
||||
setState(() {});
|
||||
SmartDialog.showToast('操作成功');
|
||||
@ -249,38 +252,40 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
||||
subtitle: Text(longPressSpeedDefault.toString()),
|
||||
)
|
||||
: const SizedBox(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 14,
|
||||
bottom: 10,
|
||||
top: 20,
|
||||
if (playSpeedSystem.isNotEmpty) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 14,
|
||||
bottom: 10,
|
||||
top: 20,
|
||||
),
|
||||
child: Text(
|
||||
'系统预设倍速',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'系统预设倍速',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 18,
|
||||
right: 18,
|
||||
bottom: 30,
|
||||
),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
spacing: 8,
|
||||
runSpacing: 2,
|
||||
children: [
|
||||
for (var i in PlaySpeed.values) ...[
|
||||
FilledButton.tonal(
|
||||
onPressed: () => showBottomSheet('system', i.index),
|
||||
child: Text(i.description),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 18,
|
||||
right: 18,
|
||||
bottom: 30,
|
||||
),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
spacing: 8,
|
||||
runSpacing: 2,
|
||||
children: [
|
||||
for (int i = 0; i < playSpeedSystem.length; i++) ...[
|
||||
FilledButton.tonal(
|
||||
onPressed: () => showBottomSheet('system', i),
|
||||
child: Text(playSpeedSystem[i].toString()),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
|
@ -91,6 +91,7 @@ class VideoDetailController extends GetxController
|
||||
late int cacheAudioQa;
|
||||
|
||||
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
||||
late bool enableRelatedVideo;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -113,7 +114,8 @@ class VideoDetailController extends GetxController
|
||||
autoPlay.value =
|
||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
||||
|
||||
enableRelatedVideo =
|
||||
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
|
||||
if (userInfo == null ||
|
||||
localCache.get(LocalCacheKey.historyPause) == true) {
|
||||
enableHeart = false;
|
||||
|
@ -521,7 +521,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
.withOpacity(0.06),
|
||||
),
|
||||
),
|
||||
const RelatedVideoPanel(),
|
||||
if (videoDetailController.videoType ==
|
||||
SearchType.video &&
|
||||
videoDetailController.enableRelatedVideo)
|
||||
const RelatedVideoPanel(),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -47,7 +47,6 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
|
||||
|
||||
class _HeaderControlState extends State<HeaderControl> {
|
||||
late PlayUrlModel videoInfo;
|
||||
List<PlaySpeed> playSpeed = PlaySpeed.values;
|
||||
static const TextStyle subTitleStyle = TextStyle(fontSize: 12);
|
||||
static const TextStyle titleStyle = TextStyle(fontSize: 14);
|
||||
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
||||
|
@ -292,11 +292,19 @@ class PlPlayerController {
|
||||
_longPressSpeed.value = videoStorage
|
||||
.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 2.0);
|
||||
}
|
||||
// 自定义倍速集合
|
||||
speedsList = List<double>.from(videoStorage
|
||||
.get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]));
|
||||
for (final PlaySpeed i in PlaySpeed.values) {
|
||||
speedsList.add(i.value);
|
||||
}
|
||||
// 默认倍速
|
||||
speedsList = List<double>.from(videoStorage
|
||||
.get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]));
|
||||
//playSpeedSystem
|
||||
final List<double> playSpeedSystem =
|
||||
videoStorage.get(VideoBoxKey.playSpeedSystem, defaultValue: playSpeed);
|
||||
|
||||
// for (final PlaySpeed i in PlaySpeed.values) {
|
||||
speedsList.addAll(playSpeedSystem);
|
||||
// }
|
||||
|
||||
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
|
||||
// if (status == PlayerStatus.playing) {
|
||||
@ -676,18 +684,6 @@ class PlPlayerController {
|
||||
_playbackSpeed.value = speed;
|
||||
}
|
||||
|
||||
/// 设置倍速
|
||||
// Future<void> togglePlaybackSpeed() async {
|
||||
// List<double> allowedSpeeds =
|
||||
// PlaySpeed.values.map<double>((e) => e.value).toList();
|
||||
// int index = allowedSpeeds.indexOf(_playbackSpeed.value);
|
||||
// if (index < allowedSpeeds.length - 1) {
|
||||
// setPlaybackSpeed(allowedSpeeds[index + 1]);
|
||||
// } else {
|
||||
// setPlaybackSpeed(allowedSpeeds[0]);
|
||||
// }
|
||||
// }
|
||||
|
||||
/// 播放视频
|
||||
/// TODO _duration.value丢失
|
||||
Future<void> play(
|
||||
|
@ -1,39 +1,15 @@
|
||||
enum PlaySpeed {
|
||||
pointTwoFive,
|
||||
pointFive,
|
||||
pointSevenFive,
|
||||
List<double> generatePlaySpeedList() {
|
||||
List<double> playSpeed = [];
|
||||
double startSpeed = 0.25;
|
||||
double endSpeed = 2.0;
|
||||
double increment = 0.25;
|
||||
|
||||
one,
|
||||
onePointTwoFive,
|
||||
onePointFive,
|
||||
onePointSevenFive,
|
||||
for (double speed = startSpeed; speed <= endSpeed; speed += increment) {
|
||||
playSpeed.add(speed);
|
||||
}
|
||||
|
||||
two,
|
||||
return playSpeed;
|
||||
}
|
||||
|
||||
extension PlaySpeedExtension on PlaySpeed {
|
||||
static final List<String> _descList = [
|
||||
'0.25',
|
||||
'0.5',
|
||||
'0.75',
|
||||
'正常',
|
||||
'1.25',
|
||||
'1.5',
|
||||
'1.75',
|
||||
'2.0',
|
||||
];
|
||||
String get description => _descList[index];
|
||||
|
||||
static final List<double> _valueList = [
|
||||
0.25,
|
||||
0.5,
|
||||
0.75,
|
||||
1.0,
|
||||
1.25,
|
||||
1.5,
|
||||
1.75,
|
||||
2.0,
|
||||
];
|
||||
double get value => _valueList[index];
|
||||
double get defaultValue => _valueList[3];
|
||||
}
|
||||
// 导出 playSpeed 列表
|
||||
List<double> playSpeed = generatePlaySpeedList();
|
||||
|
@ -99,10 +99,8 @@ class CacheManage {
|
||||
try {
|
||||
// 清除缓存 图片缓存
|
||||
await clearLibraryCache();
|
||||
Timer(const Duration(milliseconds: 500), () {
|
||||
SmartDialog.dismiss().then((res) {
|
||||
SmartDialog.showToast('清除完成');
|
||||
});
|
||||
SmartDialog.dismiss().then((res) {
|
||||
SmartDialog.showToast('清除完成');
|
||||
});
|
||||
} catch (err) {
|
||||
SmartDialog.dismiss();
|
||||
|
@ -131,7 +131,8 @@ class SettingBoxKey {
|
||||
enableSearchWord = 'enableSearchWord',
|
||||
enableSystemProxy = 'enableSystemProxy',
|
||||
enableAi = 'enableAi',
|
||||
defaultHomePage = 'defaultHomePage';
|
||||
defaultHomePage = 'defaultHomePage',
|
||||
enableRelatedVideo = 'enableRelatedVideo';
|
||||
|
||||
/// 外观
|
||||
static const String themeMode = 'themeMode',
|
||||
@ -181,6 +182,8 @@ class VideoBoxKey {
|
||||
videoSpeed = 'videoSpeed',
|
||||
// 播放顺序
|
||||
playRepeat = 'playRepeat',
|
||||
// 系统预设倍速
|
||||
playSpeedSystem = 'playSpeedSystem',
|
||||
// 默认倍速
|
||||
playSpeedDefault = 'playSpeedDefault',
|
||||
// 默认长按倍速
|
||||
|
@ -50,6 +50,9 @@ class Utils {
|
||||
return time;
|
||||
}
|
||||
if (time < 3600) {
|
||||
if (time == 0) {
|
||||
return time;
|
||||
}
|
||||
final int minute = time ~/ 60;
|
||||
final double res = time / 60;
|
||||
if (minute != res) {
|
||||
@ -87,6 +90,9 @@ class Utils {
|
||||
|
||||
// 时间显示,刚刚,x分钟前
|
||||
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
||||
if (timeStamp == 0 || timeStamp == null || timeStamp == '') {
|
||||
return '';
|
||||
}
|
||||
// 当前时间
|
||||
int time = (DateTime.now().millisecondsSinceEpoch / 1000).round();
|
||||
// 对比
|
||||
@ -103,6 +109,7 @@ class Utils {
|
||||
toInt: false,
|
||||
formatType: formatType);
|
||||
}
|
||||
print('distance: $distance');
|
||||
if (distance <= 60) {
|
||||
return '刚刚';
|
||||
} else if (distance <= 3600) {
|
||||
@ -236,6 +243,10 @@ class Utils {
|
||||
SmartDialog.dismiss();
|
||||
var currentInfo = await PackageInfo.fromPlatform();
|
||||
var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
|
||||
if (result.data == null || result.data.isEmpty) {
|
||||
SmartDialog.showToast('获取远程版本失败,请检查网络');
|
||||
return false;
|
||||
}
|
||||
LatestDataModel data = LatestDataModel.fromJson(result.data);
|
||||
bool isUpdate = Utils.needUpdate(currentInfo.version, data.tagName!);
|
||||
if (isUpdate) {
|
||||
@ -344,9 +355,8 @@ class Utils {
|
||||
}
|
||||
|
||||
static List<int> generateRandomBytes(int minLength, int maxLength) {
|
||||
return List<int>.generate(
|
||||
random.nextInt(maxLength-minLength+1), (_) => random.nextInt(0x60) + 0x20
|
||||
);
|
||||
return List<int>.generate(random.nextInt(maxLength - minLength + 1),
|
||||
(_) => random.nextInt(0x60) + 0x20);
|
||||
}
|
||||
|
||||
static String base64EncodeRandomString(int minLength, int maxLength) {
|
||||
|
Reference in New Issue
Block a user