基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
add advanced danmaku support
Prediditf2e491688c3a
diff --git a/lib/modules/danmaku/danmaku_module.dart b/lib/modules/danmaku/danmaku_module.dartindex a2d15b33..cb28c478 100644--- a/lib/modules/danmaku/danmaku_module.dart+++ b/lib/modules/danmaku/danmaku_module.dart@@ -1,13 +1,24 @@+import 'package:flutter/material.dart';+import 'package:kazumi/utils/utils.dart';+class Danmaku {- double p;- String m;+ // 弹幕内容+ String message;+ // 弹幕时间+ double time;+ // 弹幕类型 (1-普通弹幕,4-底部弹幕,5-顶部弹幕)+ int type;+ // 弹幕颜色+ Color color;- Danmaku({required this.p, required this.m});+ Danmaku({required this.message, required this.time, required this.type, required this.color});factory Danmaku.fromJson(Map<String, dynamic> json) {+ String messageValue = json['m'];List<String> parts = json['p'].split(',');- double pValue = double.parse(parts[0]);- String mValue = json['m'];- return Danmaku(p: pValue, m: mValue);+ double timeValue = double.parse(parts[0]);+ int typeValue = int.parse(parts[1]);+ Color color = Utils.generateDanmakuColor(int.parse(parts[2]));+ return Danmaku(time: timeValue, message: messageValue, type: typeValue, color: color);}}\ No newline at end of filediff --git a/lib/pages/about/about_page.dart b/lib/pages/about/about_page.dartindex 493ef758..3b0d01ab 100644--- a/lib/pages/about/about_page.dart+++ b/lib/pages/about/about_page.dart@@ -51,7 +51,7 @@ class _AboutPageState extends State<AboutPage> {},child: Scaffold(appBar: const SysAppBar(title: Text('关于')),- backgroundColor: Colors.transparent,+ // backgroundColor: Colors.transparent,body: Column(children: [ListTile(diff --git a/lib/pages/player/player_controller.dart b/lib/pages/player/player_controller.dartindex 47f99db8..ed446b32 100644--- a/lib/pages/player/player_controller.dart+++ b/lib/pages/player/player_controller.dart@@ -187,9 +187,9 @@ abstract class _PlayerController with Store {void addDanmakus(List<Danmaku> danmakus) {for (var element in danmakus) {var danmakuList =- danDanmakus[element.p.toInt()] ?? List.empty(growable: true);+ danDanmakus[element.time.toInt()] ?? List.empty(growable: true);danmakuList.add(element);- danDanmakus[element.p.toInt()] = danmakuList;+ danDanmakus[element.time.toInt()] = danmakuList;}}}diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dartindex 817b428c..6a424f66 100644--- a/lib/pages/player/player_item.dart+++ b/lib/pages/player/player_item.dart@@ -107,7 +107,14 @@ class _PlayerItemState extends State<PlayerItem> with WindowListener {playerController.currentPosition.inSeconds]!.length),() => mounted && playerController.mediaPlayer.state.playing- ? danmakuController.addDanmaku(DanmakuContentItem(danmaku.m))+ ? danmakuController.addDanmaku(DanmakuContentItem(+ danmaku.message,+ color: danmaku.color,+ type: danmaku.type == 4+ ? DanmakuItemType.bottom+ : (danmaku.type == 5+ ? DanmakuItemType.top+ : DanmakuItemType.scroll))): null);});}@@ -250,11 +257,11 @@ class _PlayerItemState extends State<PlayerItem> with WindowListener {super.initState();if (Platform.isAndroid || Platform.isIOS) {navigationBarState =- Provider.of<NavigationBarState>(context, listen: false);+ Provider.of<NavigationBarState>(context, listen: false);} else {navigationBarState =- Provider.of<SideNavigationBarState>(context, listen: false);- }+ Provider.of<SideNavigationBarState>(context, listen: false);+ }playerTimer = getPlayerTimer();}@@ -270,7 +277,6 @@ class _PlayerItemState extends State<PlayerItem> with WindowListener {@overrideWidget build(BuildContext context) {// 弹幕设置- // bool _running = true;bool _border = setting.get(SettingBoxKey.danmakuBorder, defaultValue: true);double _opacity =setting.get(SettingBoxKey.danmakuOpacity, defaultValue: 1.0);@@ -284,6 +290,8 @@ class _PlayerItemState extends State<PlayerItem> with WindowListener {!setting.get(SettingBoxKey.danmakuBottom, defaultValue: true);bool _hideScroll =!setting.get(SettingBoxKey.danmakuScroll, defaultValue: true);+ bool _massiveMode =+ setting.get(SettingBoxKey.danmakuMassive, defaultValue: false);isFavorite = favoriteController.isFavorite(infoController.bangumiItem);@@ -659,6 +667,8 @@ class _PlayerItemState extends State<PlayerItem> with WindowListener {opacity: _opacity,fontSize: _fontSize,duration: _duration.toInt(),+ showStroke: _border,+ massiveMode: _massiveMode,),),),diff --git a/lib/pages/settings/danmaku_settings.dart b/lib/pages/settings/danmaku_settings.dartindex f7950aae..67c7d339 100644--- a/lib/pages/settings/danmaku_settings.dart+++ b/lib/pages/settings/danmaku_settings.dart@@ -91,6 +91,35 @@ class _DanmakuSettingsPageState extends State<DanmakuSettingsPage> {defaultVal: true,),),+ const InkWell(+ child: SetSwitchItem(+ title: '顶部弹幕',+ setKey: SettingBoxKey.danmakuTop,+ defaultVal: true,+ ),+ ),+ const InkWell(+ child: SetSwitchItem(+ title: '底部弹幕',+ setKey: SettingBoxKey.danmakuBottom,+ defaultVal: true,+ ),+ ),+ const InkWell(+ child: SetSwitchItem(+ title: '滚动弹幕',+ setKey: SettingBoxKey.danmakuScroll,+ defaultVal: true,+ ),+ ),+ const InkWell(+ child: SetSwitchItem(+ title: '海量弹幕',+ subTitle: '弹幕过多时进行叠加绘制',+ setKey: SettingBoxKey.danmakuMassive,+ defaultVal: false,+ ),+ ),ListTile(onTap: () async {final List<double> danFontList = [diff --git a/lib/utils/storage.dart b/lib/utils/storage.dartindex 6ec67367..bab1235b 100644--- a/lib/utils/storage.dart+++ b/lib/utils/storage.dart@@ -32,6 +32,7 @@ class SettingBoxKey {danmakuTop = 'danmakuTop',danmakuScroll = 'danmakuScroll',danmakuBottom = 'danmakuBottom',+ danmakuMassive = 'danmakuMassive',danmakuArea = 'danmakuArea',themeMode = 'themeMode',themeColor = 'themeColor',diff --git a/lib/utils/utils.dart b/lib/utils/utils.dartindex 531a7c22..64f5a67d 100644--- a/lib/utils/utils.dart+++ b/lib/utils/utils.dart@@ -359,4 +359,14 @@ class Utils {),);}++ static generateDanmakuColor(int colorValue) {+ // 提取颜色分量+ int red = (colorValue >> 16) & 0xFF;+ int green = (colorValue >> 8) & 0xFF;+ int blue = colorValue & 0xFF;+ // 创建Color对象+ Color color = Color.fromARGB(255, red, green, blue);+ return color;+ }}