Compare commits

..

5 Commits

Author SHA1 Message Date
b689db16b5 Merge branch 'main' into feature-media_kit 2024-03-30 17:13:09 +08:00
76784ee664 mod: seekTo 2024-03-19 23:33:32 +08:00
2dbef3fee2 mod: media_kit引入 2024-03-19 23:23:14 +08:00
3a66c8c03d Merge branch 'main' into feature-media_kit 2024-03-19 23:15:06 +08:00
6f62837495 mod: media_kit依赖 2024-02-02 23:12:04 +08:00
17 changed files with 118 additions and 244 deletions

View File

@ -506,6 +506,4 @@ class Api {
/// 排行榜
static const String getRankApi = "/x/web-interface/ranking/v2";
/// 取消订阅
static const String cancelSub = '/x/v3/fav/season/unfav';
}

View File

@ -349,21 +349,4 @@ class UserHttp {
return {'status': false, 'msg': res.data['message']};
}
}
// 取消订阅
static Future cancelSub({required int seasonId}) async {
var res = await Request().post(
Api.cancelSub,
queryParameters: {
'platform': 'web',
'season_id': seasonId,
'csrf': await Request.getCsrf(),
},
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
}

View File

@ -34,7 +34,6 @@ void main() async {
.then((_) async {
await GStrorage.init();
await setupServiceLocator();
clearLogs();
Request();
await Request.setCookie();
RecommendFilter();

View File

@ -47,23 +47,18 @@ class Vip {
this.status,
this.dueDate,
this.label,
this.nicknameColor,
});
int? type;
int? status;
int? dueDate;
Map? label;
int? nicknameColor;
Vip.fromJson(Map<String, dynamic> json) {
type = json['type'];
status = json['status'];
dueDate = json['due_date'];
label = json['label'];
nicknameColor = json['nickname_color'] == ''
? null
: int.parse("0xFF${json['nickname_color'].replaceAll('#', '')}");
}
}

View File

@ -258,27 +258,24 @@ class HistoryItem extends StatelessWidget {
),
),
),
videoItem.progress != 0
? Positioned(
left: 3,
right: 3,
bottom: 0,
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(
StyleString.imgRadius.x),
bottomRight: Radius.circular(
StyleString.imgRadius.x),
),
child: LinearProgressIndicator(
value: videoItem.progress == -1
? 100
: videoItem.progress /
videoItem.duration,
),
),
)
: const SizedBox()
Positioned(
left: 3,
right: 3,
bottom: 0,
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft:
Radius.circular(StyleString.imgRadius.x),
bottomRight:
Radius.circular(StyleString.imgRadius.x),
),
child: LinearProgressIndicator(
value: videoItem.progress == -1
? 100
: videoItem.progress / videoItem.duration,
),
),
)
],
),
VideoContent(videoItem: videoItem, ctr: ctr)

View File

@ -281,8 +281,8 @@ class _MemberPageState extends State<MemberPage>
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
Map? data = snapshot.data;
if (data != null && data['status']) {
Map data = snapshot.data!;
if (data['status']) {
return Obx(
() => Stack(
alignment: AlignmentDirectional.center,
@ -302,14 +302,7 @@ class _MemberPageState extends State<MemberPage>
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight: FontWeight.bold,
color: _memberController.memberInfo.value
.vip!.nicknameColor !=
null
? Color(_memberController.memberInfo
.value.vip!.nicknameColor!)
: null),
.copyWith(fontWeight: FontWeight.bold),
)),
const SizedBox(width: 2),
if (_memberController.memberInfo.value.sex == '')

View File

@ -18,32 +18,45 @@ class MemberSeasonsPanel extends StatelessWidget {
itemBuilder: (context, index) {
MemberSeasonsList item = data!.seasonsList![index];
return Padding(
padding: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.only(bottom: 12, right: 4),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListTile(
onTap: () => Get.toNamed(
'/memberSeasons?mid=${item.meta!.mid}&seasonId=${item.meta!.seasonId}'),
title: Text(
item.meta!.name!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleSmall!,
),
dense: true,
leading: PBadge(
stack: 'relative',
size: 'small',
text: item.meta!.total.toString(),
),
trailing: const Icon(
Icons.arrow_forward,
size: 20,
Padding(
padding: const EdgeInsets.only(bottom: 12, left: 4),
child: Row(
children: [
Text(
item.meta!.name!,
maxLines: 1,
style: Theme.of(context).textTheme.titleSmall!,
),
const SizedBox(width: 10),
PBadge(
stack: 'relative',
size: 'small',
text: item.meta!.total.toString(),
),
const Spacer(),
SizedBox(
width: 35,
height: 35,
child: IconButton(
onPressed: () => Get.toNamed(
'/memberSeasons?mid=${item.meta!.mid}&seasonId=${item.meta!.seasonId}'),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
icon: const Icon(
Icons.arrow_forward,
size: 20,
),
),
)
],
),
),
const SizedBox(height: 10),
LayoutBuilder(
builder: (context, boxConstraints) {
return GridView.builder(

View File

@ -46,40 +46,4 @@ class SubController extends GetxController {
Future onLoad() async {
querySubFolder(type: 'onload');
}
// 取消订阅
Future<void> cancelSub(SubFolderItemData subFolderItem) async {
showDialog(
context: Get.context!,
builder: (context) => AlertDialog(
title: const Text('提示'),
content: const Text('确定取消订阅吗?'),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
var res = await UserHttp.cancelSub(seasonId: subFolderItem.id!);
if (res['status']) {
subFolderData.value.list!.remove(subFolderItem);
subFolderData.update((val) {});
SmartDialog.showToast('取消订阅成功');
} else {
SmartDialog.showToast(res['msg']);
}
Get.back();
},
child: const Text('确定'),
),
],
),
);
}
}

View File

@ -58,8 +58,7 @@ class _SubPageState extends State<SubPage> {
itemBuilder: (context, index) {
return SubItem(
subFolderItem:
_subController.subFolderData.value.list![index],
cancelSub: _subController.cancelSub);
_subController.subFolderData.value.list![index]);
},
),
);

View File

@ -8,12 +8,7 @@ import '../../../models/user/sub_folder.dart';
class SubItem extends StatelessWidget {
final SubFolderItemData subFolderItem;
final Function(SubFolderItemData) cancelSub;
const SubItem({
super.key,
required this.subFolderItem,
required this.cancelSub,
});
const SubItem({super.key, required this.subFolderItem});
@override
Widget build(BuildContext context) {
@ -56,10 +51,7 @@ class SubItem extends StatelessWidget {
},
),
),
VideoContent(
subFolderItem: subFolderItem,
cancelSub: cancelSub,
)
VideoContent(subFolderItem: subFolderItem)
],
),
);
@ -72,8 +64,7 @@ class SubItem extends StatelessWidget {
class VideoContent extends StatelessWidget {
final SubFolderItemData subFolderItem;
final Function(SubFolderItemData)? cancelSub;
const VideoContent({super.key, required this.subFolderItem, this.cancelSub});
const VideoContent({super.key, required this.subFolderItem});
@override
Widget build(BuildContext context) {
@ -109,24 +100,6 @@ class VideoContent extends StatelessWidget {
color: Theme.of(context).colorScheme.outline,
),
),
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: 35,
width: 35,
child: IconButton(
onPressed: () => cancelSub?.call(subFolderItem),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.outline,
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
),
icon: const Icon(Icons.delete_outline, size: 18),
),
)
],
)
],
),
),

View File

@ -91,7 +91,7 @@ class VideoDetailController extends GetxController
late bool enableCDN;
late int? cacheVideoQa;
late String cacheDecode;
late int defaultAudioQa;
late int cacheAudioQa;
PersistentBottomSheetController? replyReplyBottomSheetCtr;
RxList<SubTitileContentModel> subtitleContents =
@ -146,7 +146,7 @@ class VideoDetailController extends GetxController
// 预设的解码格式
cacheDecode = setting.get(SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormats.values.last.code);
defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
cacheAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
defaultValue: AudioQuality.hiRes.code);
oid.value = IdUtils.bv2av(Get.parameters['bvid']!);
getSubtitle();
@ -353,9 +353,9 @@ class VideoDetailController extends GetxController
if (audiosList.isNotEmpty) {
final List<int> numbers = audiosList.map((map) => map.id!).toList();
int closestNumber = Utils.findClosestNumber(defaultAudioQa, numbers);
if (!numbers.contains(defaultAudioQa) &&
numbers.any((e) => e > defaultAudioQa)) {
int closestNumber = Utils.findClosestNumber(cacheAudioQa, numbers);
if (!numbers.contains(cacheAudioQa) &&
numbers.any((e) => e > cacheAudioQa)) {
closestNumber = 30280;
}
firstAudio = audiosList.firstWhere((e) => e.id == closestNumber);

View File

@ -525,18 +525,14 @@ InlineSpan buildContent(
if (jumpUrlKeysList.isNotEmpty) {
patternStr += '|${jumpUrlKeysList.join('|')}';
}
RegExp bv23Regex = RegExp(r'https://b23\.tv/[a-zA-Z0-9]{7}');
final RegExp pattern = RegExp(patternStr);
List<String> matchedStrs = [];
void addPlainTextSpan(str) {
spanChilds.add(
TextSpan(
spanChilds.add(TextSpan(
text: str,
recognizer: TapGestureRecognizer()
..onTap = () =>
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem),
),
);
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem)));
}
// 分割文本并处理每个部分
@ -738,36 +734,8 @@ InlineSpan buildContent(
return '';
},
onNonMatch: (String nonMatchStr) {
return nonMatchStr.splitMapJoin(
bv23Regex,
onMatch: (Match match) {
String matchStr = match[0]!;
spanChilds.add(
TextSpan(
text: ' $matchStr ',
style: isVideoPage
? TextStyle(
color: Theme.of(context).colorScheme.primary,
)
: null,
recognizer: TapGestureRecognizer()
..onTap = () => Get.toNamed(
'/webview',
parameters: {
'url': matchStr,
'type': 'url',
'pageTitle': matchStr
},
),
),
);
return '';
},
onNonMatch: (String nonMatchOtherStr) {
addPlainTextSpan(nonMatchOtherStr);
return nonMatchOtherStr;
},
);
addPlainTextSpan(nonMatchStr);
return nonMatchStr;
},
);

View File

@ -142,10 +142,9 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
@override
Widget build(BuildContext context) {
double _keyboardHeight = EdgeInsets.fromViewPadding(
double keyboardHeight = EdgeInsets.fromViewPadding(
View.of(context).viewInsets, View.of(context).devicePixelRatio)
.bottom;
print('_keyboardHeight: $_keyboardHeight');
return Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
@ -236,11 +235,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
duration: const Duration(milliseconds: 300),
child: SizedBox(
width: double.infinity,
height: toolbarType == 'input'
? (_keyboardHeight > keyboardHeight
? _keyboardHeight
: keyboardHeight)
: emoteHeight,
height: toolbarType == 'input' ? keyboardHeight : emoteHeight,
child: EmotePanel(
onChoose: (package, emote) => onChooseEmote(package, emote),
),

View File

@ -393,7 +393,13 @@ class PlPlayerController {
}
// 配置Player 音轨、字幕等等
_videoPlayerController = await _createVideoController(
dataSource, _looping, enableHA, width, height);
dataSource,
_looping,
enableHA,
width,
height,
seekTo,
);
// 获取视频时长 00:00
_duration.value = duration ?? _videoPlayerController!.state.duration;
updateDurationSecond();
@ -404,7 +410,7 @@ class PlPlayerController {
if (!_listenersInitialized) {
startListeners();
}
await _initializePlayer(seekTo: seekTo, duration: _duration.value);
await _initializePlayer(duration: _duration.value);
bool autoEnterFullcreen =
setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
if (autoEnterFullcreen && _isFirstTime) {
@ -424,6 +430,7 @@ class PlPlayerController {
bool enableHA,
double? width,
double? height,
Duration? seekTo,
) async {
// 每次配置时先移除监听
removeListeners();
@ -506,7 +513,11 @@ class PlPlayerController {
);
}
player.open(
Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders),
Media(
dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders,
start: seekTo ?? Duration.zero,
),
play: false,
);
// 音轨
@ -519,7 +530,6 @@ class PlPlayerController {
// 开始播放
Future _initializePlayer({
Duration seekTo = Duration.zero,
Duration? duration,
}) async {
// 设置倍速
@ -537,11 +547,6 @@ class PlPlayerController {
// await setLooping(_looping);
// }
// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
// 自动播放
if (_autoPlay) {
await play(duration: duration);
@ -661,21 +666,14 @@ class PlPlayerController {
await _videoPlayerController?.stream.buffer.first;
}
await _videoPlayerController?.seek(position);
// if (playerStatus.stopped) {
// play();
// }
} else {
print('seek duration else');
_timerForSeek?.cancel();
_timerForSeek =
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
//_timerForSeek = null;
if (duration.value.inSeconds != 0) {
await _videoPlayerController!.stream.buffer.first;
await _videoPlayerController?.seek(position);
// if (playerStatus.status.value == PlayerStatus.paused) {
// play();
// }
t.cancel();
_timerForSeek = null;
}

View File

@ -51,7 +51,7 @@ class Utils {
}
if (time < 3600) {
if (time == 0) {
return '00:00';
return time;
}
final int minute = time ~/ 60;
final double res = time / 60;
@ -208,35 +208,17 @@ class Utils {
static int findClosestNumber(int target, List<int> numbers) {
int minDiff = 127;
int closestNumber = 0; // 初始化为0表示没有找到比目标值小的整数
// 向下查找
late int closestNumber;
try {
for (int number in numbers) {
if (number < target) {
int diff = target - number; // 计算目标值与当前整数的差值
int diff = (number - target).abs();
if (diff < minDiff) {
minDiff = diff;
closestNumber = number;
}
if (diff < minDiff) {
minDiff = diff;
closestNumber = number;
}
}
} catch (_) {}
// 向上查找
if (closestNumber == 0) {
try {
for (int number in numbers) {
int diff = (number - target).abs();
if (diff < minDiff) {
minDiff = diff;
closestNumber = number;
}
}
} catch (_) {}
}
return closestNumber;
}

View File

@ -865,10 +865,11 @@ packages:
media_kit:
dependency: "direct main"
description:
name: media_kit
sha256: "3289062540e3b8b9746e5c50d95bd78a9289826b7227e253dff806d002b9e67a"
url: "https://pub.flutter-io.cn"
source: hosted
path: media_kit
ref: HEAD
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.1.10+1"
media_kit_libs_android_video:
dependency: transitive
@ -905,10 +906,11 @@ packages:
media_kit_libs_video:
dependency: "direct main"
description:
name: media_kit_libs_video
sha256: "3688e0c31482074578652bf038ce6301a5d21e1eda6b54fc3117ffeb4bdba067"
url: "https://pub.flutter-io.cn"
source: hosted
path: "libs/universal/media_kit_libs_video"
ref: HEAD
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.0.4"
media_kit_libs_windows_video:
dependency: transitive
@ -929,10 +931,11 @@ packages:
media_kit_video:
dependency: "direct main"
description:
name: media_kit_video
sha256: c048d11a19e379aebbe810647636e3fc6d18374637e2ae12def4ff8a4b99a882
url: "https://pub.flutter-io.cn"
source: hosted
path: media_kit_video
ref: HEAD
resolved-ref: "77a130b1d7ce733b47d2133b57563716090450d0"
url: "https://github.com/media-kit/media-kit.git"
source: git
version: "1.2.4"
meta:
dependency: transitive

View File

@ -163,6 +163,20 @@ dev_dependencies:
hive_generator: ^2.0.0
build_runner: ^2.4.8
dependency_overrides:
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
path: libs/universal/media_kit_libs_video
flutter_launcher_icons:
android: true
ios: true