Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

add player aspectradio support

Prediditfb94096796ef
diff --git a/lib/pages/player/player_controller.dart b/lib/pages/player/player_controller.dart
index 23912fd9..5472e0d2 100644
--- a/lib/pages/player/player_controller.dart
+++ b/lib/pages/player/player_controller.dart
@@ -51,6 +51,13 @@ abstract class _PlayerController with Store {
@observable
bool danmakuOn = false;
+ // 视频比例类型
+ // 1. AUTO
+ // 2. COVER
+ // 3. FILL
+ @observable
+ int aspectRatioType = 1;
+
// 视频音量/亮度
@observable
double volume = 0;
diff --git a/lib/pages/player/player_controller.g.dart b/lib/pages/player/player_controller.g.dart
index 55096b63..74d56850 100644
--- a/lib/pages/player/player_controller.g.dart
+++ b/lib/pages/player/player_controller.g.dart
@@ -153,6 +153,22 @@ mixin _$PlayerController on _PlayerController, Store {
});
}
+ late final _$aspectRatioTypeAtom =
+ Atom(name: '_PlayerController.aspectRatioType', context: context);
+
+ @override
+ int get aspectRatioType {
+ _$aspectRatioTypeAtom.reportRead();
+ return super.aspectRatioType;
+ }
+
+ @override
+ set aspectRatioType(int value) {
+ _$aspectRatioTypeAtom.reportWrite(value, super.aspectRatioType, () {
+ super.aspectRatioType = value;
+ });
+ }
+
late final _$volumeAtom =
Atom(name: '_PlayerController.volume', context: context);
@@ -213,6 +229,7 @@ currentPosition: ${currentPosition},
buffer: ${buffer},
duration: ${duration},
danmakuOn: ${danmakuOn},
+aspectRatioType: ${aspectRatioType},
volume: ${volume},
brightness: ${brightness},
playerSpeed: ${playerSpeed}
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart
index c1f1630d..86bb96c4 100644
--- a/lib/pages/player/player_item.dart
+++ b/lib/pages/player/player_item.dart
@@ -383,8 +383,7 @@ class _PlayerItemState extends State<PlayerItem>
Utils.enterFullScreen();
videoPageController.showTabBody = false;
}
- videoPageController.isFullscreen =
- !videoPageController.isFullscreen;
+ videoPageController.isFullscreen = !videoPageController.isFullscreen;
}
void _handleDanmaku() {
@@ -1289,8 +1288,7 @@ class _PlayerItemState extends State<PlayerItem>
),
// 右侧锁定按钮
- (Utils.isDesktop() ||
- !videoPageController.isFullscreen)
+ (Utils.isDesktop() || !videoPageController.isFullscreen)
? Container()
: Positioned(
right: 0,
@@ -1349,6 +1347,48 @@ class _PlayerItemState extends State<PlayerItem>
child: dtb.DragToMoveArea(
child: SizedBox(height: 40)),
),
+ PopupMenuButton(
+ tooltip: '',
+ child: Text(
+ playerController.aspectRatioType == 1
+ ? 'AUTO'
+ : playerController.aspectRatioType == 2
+ ? 'COVER'
+ : 'FILL',
+ style: const TextStyle(
+ color: Colors.white,
+ fontSize: 12,
+ fontWeight: FontWeight.bold
+ )),
+ itemBuilder: (context) {
+ return const [
+ PopupMenuItem(
+ value: 1,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [Text("AUTO")],
+ ),
+ ),
+ PopupMenuItem(
+ value: 2,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [Text("COVER")],
+ ),
+ ),
+ PopupMenuItem(
+ value: 3,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [Text("FILL")],
+ ),
+ ),
+ ];
+ },
+ onSelected: (value) {
+ playerController.aspectRatioType = value;
+ },
+ ),
TextButton(
style: ButtonStyle(
padding:
@@ -1363,6 +1403,7 @@ class _PlayerItemState extends State<PlayerItem>
style: const TextStyle(
color: Colors.white,
fontSize: 12,
+ fontWeight: FontWeight.bold
),
),
),
@@ -1684,32 +1725,41 @@ class _PlayerItemState extends State<PlayerItem>
}
Widget get playerSurface {
- return Video(
- controller: playerController.videoController,
- controls: NoVideoControls,
- subtitleViewConfiguration: SubtitleViewConfiguration(
- style: TextStyle(
- color: Colors.pink,
- fontSize: 48.0,
- background: Paint()..color = Colors.transparent,
- decoration: TextDecoration.none,
- fontWeight: FontWeight.bold,
- shadows: const [
- Shadow(
- offset: Offset(1.0, 1.0),
- blurRadius: 3.0,
- color: Color.fromARGB(255, 255, 255, 255),
- ),
- Shadow(
- offset: Offset(-1.0, -1.0),
- blurRadius: 3.0,
- color: Color.fromARGB(125, 255, 255, 255),
+ return Observer(
+ builder: (context) {
+ return Video(
+ controller: playerController.videoController,
+ controls: NoVideoControls,
+ fit: playerController.aspectRatioType == 1
+ ? BoxFit.contain
+ : playerController.aspectRatioType == 2
+ ? BoxFit.cover
+ : BoxFit.fill,
+ subtitleViewConfiguration: SubtitleViewConfiguration(
+ style: TextStyle(
+ color: Colors.pink,
+ fontSize: 48.0,
+ background: Paint()..color = Colors.transparent,
+ decoration: TextDecoration.none,
+ fontWeight: FontWeight.bold,
+ shadows: const [
+ Shadow(
+ offset: Offset(1.0, 1.0),
+ blurRadius: 3.0,
+ color: Color.fromARGB(255, 255, 255, 255),
+ ),
+ Shadow(
+ offset: Offset(-1.0, -1.0),
+ blurRadius: 3.0,
+ color: Color.fromARGB(125, 255, 255, 255),
+ ),
+ ],
),
- ],
- ),
- textAlign: TextAlign.center,
- padding: const EdgeInsets.all(24.0),
- ),
+ textAlign: TextAlign.center,
+ padding: const EdgeInsets.all(24.0),
+ ),
+ );
+ }
);
}
}