opt: videoPlayer control
This commit is contained in:
BIN
assets/images/video/dlna.png
Executable file
BIN
assets/images/video/dlna.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/images/video/fullscreen.png
Executable file
BIN
assets/images/video/fullscreen.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 274 B |
BIN
assets/images/video/fullscreen_exit.png
Executable file
BIN
assets/images/video/fullscreen_exit.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 246 B |
BIN
assets/images/video/pip.png
Executable file
BIN
assets/images/video/pip.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -115,6 +115,7 @@ class VideoDetailController extends GetxController
|
|||||||
BottomControlType.time,
|
BottomControlType.time,
|
||||||
BottomControlType.space,
|
BottomControlType.space,
|
||||||
BottomControlType.fit,
|
BottomControlType.fit,
|
||||||
|
BottomControlType.speed,
|
||||||
BottomControlType.fullscreen,
|
BottomControlType.fullscreen,
|
||||||
].obs;
|
].obs;
|
||||||
RxDouble sheetHeight = 0.0.obs;
|
RxDouble sheetHeight = 0.0.obs;
|
||||||
|
@ -56,7 +56,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
final Box<dynamic> localCache = GStorage.localCache;
|
final Box<dynamic> localCache = GStorage.localCache;
|
||||||
final Box<dynamic> videoStorage = GStorage.video;
|
final Box<dynamic> videoStorage = GStorage.video;
|
||||||
late List<double> speedsList;
|
late List<double> speedsList;
|
||||||
double buttonSpace = 8;
|
double buttonSpace = 4;
|
||||||
RxBool isFullScreen = false.obs;
|
RxBool isFullScreen = false.obs;
|
||||||
late String heroTag;
|
late String heroTag;
|
||||||
late VideoIntroController videoIntroController;
|
late VideoIntroController videoIntroController;
|
||||||
@ -486,65 +486,6 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 选择倍速
|
|
||||||
void showSetSpeedSheet() {
|
|
||||||
final double currentSpeed = widget.controller!.playbackSpeed;
|
|
||||||
showDialog(
|
|
||||||
context: Get.context!,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('播放速度'),
|
|
||||||
content: StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
return Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
runSpacing: 2,
|
|
||||||
children: [
|
|
||||||
for (final double i in speedsList) ...<Widget>[
|
|
||||||
if (i == currentSpeed) ...<Widget>[
|
|
||||||
FilledButton(
|
|
||||||
onPressed: () async {
|
|
||||||
// setState(() => currentSpeed = i),
|
|
||||||
await widget.controller!.setPlaybackSpeed(i);
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: Text(i.toString()),
|
|
||||||
),
|
|
||||||
] else ...[
|
|
||||||
FilledButton.tonal(
|
|
||||||
onPressed: () async {
|
|
||||||
// setState(() => currentSpeed = i),
|
|
||||||
await widget.controller!.setPlaybackSpeed(i);
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: Text(i.toString()),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await widget.controller!.setDefaultSpeed();
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: const Text('默认速度'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 选择画质
|
/// 选择画质
|
||||||
void showSetVideoQa() {
|
void showSetVideoQa() {
|
||||||
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
||||||
@ -1222,7 +1163,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
fuc: () async {
|
fuc: () async {
|
||||||
// 销毁播放器实例
|
// 销毁播放器实例
|
||||||
await widget.controller!.dispose(type: 'all');
|
await widget.controller!.dispose(type: 'all');
|
||||||
if (mounted) {
|
if (context.mounted) {
|
||||||
Navigator.popUntil(
|
Navigator.popUntil(
|
||||||
context, (Route<dynamic> route) => route.isFirst);
|
context, (Route<dynamic> route) => route.isFirst);
|
||||||
}
|
}
|
||||||
@ -1230,21 +1171,9 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// ComBtn(
|
|
||||||
// icon: const Icon(
|
|
||||||
// FontAwesomeIcons.cropSimple,
|
|
||||||
// size: 15,
|
|
||||||
// color: Colors.white,
|
|
||||||
// ),
|
|
||||||
// fuc: () => _.screenshot(),
|
|
||||||
// ),
|
|
||||||
if (GlobalDataCache.enableDlna) ...[
|
if (GlobalDataCache.enableDlna) ...[
|
||||||
ComBtn(
|
ComBtn(
|
||||||
icon: const Icon(
|
icon: Image.asset('assets/images/video/dlna.png', width: 19),
|
||||||
Icons.cast,
|
|
||||||
size: 19,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
fuc: () async {
|
fuc: () async {
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
@ -1255,7 +1184,10 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
SizedBox(width: buttonSpace),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/// 弹幕开关(全屏时)
|
||||||
if (isFullScreen.value) ...[
|
if (isFullScreen.value) ...[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 56,
|
width: 56,
|
||||||
@ -1271,6 +1203,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(width: buttonSpace),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 34,
|
width: 34,
|
||||||
height: 34,
|
height: 34,
|
||||||
@ -1292,8 +1225,10 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(width: buttonSpace),
|
||||||
],
|
],
|
||||||
SizedBox(width: buttonSpace),
|
|
||||||
|
/// pip
|
||||||
if (Platform.isAndroid) ...<Widget>[
|
if (Platform.isAndroid) ...<Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 34,
|
width: 34,
|
||||||
@ -1318,9 +1253,9 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
await widget.floating!.enable(aspectRatio: aspectRatio);
|
await widget.floating!.enable(aspectRatio: aspectRatio);
|
||||||
} else {}
|
} else {}
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: Image.asset(
|
||||||
Icons.picture_in_picture_outlined,
|
'assets/images/video/pip.png',
|
||||||
size: 19,
|
width: 19,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1329,37 +1264,21 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
],
|
],
|
||||||
|
|
||||||
/// 字幕
|
/// 字幕
|
||||||
if (widget.showSubtitleBtn)
|
if (widget.showSubtitleBtn) ...[
|
||||||
ComBtn(
|
ComBtn(
|
||||||
icon: const Icon(
|
icon: Icon(
|
||||||
Icons.closed_caption_off,
|
FontAwesomeIcons.closedCaptioning,
|
||||||
size: 22,
|
size: 16,
|
||||||
color: Colors.white,
|
color: Colors.white.withOpacity(0.9),
|
||||||
),
|
),
|
||||||
fuc: () => showSubtitleDialog(),
|
fuc: () => showSubtitleDialog(),
|
||||||
),
|
),
|
||||||
SizedBox(width: buttonSpace),
|
SizedBox(width: buttonSpace),
|
||||||
Obx(
|
],
|
||||||
() => SizedBox(
|
|
||||||
width: 45,
|
|
||||||
height: 34,
|
|
||||||
child: TextButton(
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
|
||||||
),
|
|
||||||
onPressed: () => showSetSpeedSheet(),
|
|
||||||
child: Text(
|
|
||||||
'${_.playbackSpeed}X',
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: buttonSpace),
|
|
||||||
ComBtn(
|
ComBtn(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.more_vert_outlined,
|
Icons.more_vert_outlined,
|
||||||
size: 18,
|
size: 19,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
fuc: () => showSettingSheet(),
|
fuc: () => showSettingSheet(),
|
||||||
|
@ -6,6 +6,7 @@ import 'dart:typed_data';
|
|||||||
|
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
|
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
@ -113,12 +114,13 @@ class PlPlayerController {
|
|||||||
// final Durations durations;
|
// final Durations durations;
|
||||||
|
|
||||||
List<Map<String, dynamic>> videoFitType = [
|
List<Map<String, dynamic>> videoFitType = [
|
||||||
{'attr': BoxFit.contain, 'desc': '包含'},
|
{'attr': BoxFit.contain, 'desc': '自动'},
|
||||||
{'attr': BoxFit.cover, 'desc': '覆盖'},
|
{'attr': BoxFit.cover, 'desc': '铺满'},
|
||||||
{'attr': BoxFit.fill, 'desc': '填充'},
|
{'attr': BoxFit.fill, 'desc': '填满'},
|
||||||
{'attr': BoxFit.fitHeight, 'desc': '高度适应'},
|
{'attr': BoxFit.fitHeight, 'desc': '等高'},
|
||||||
{'attr': BoxFit.fitWidth, 'desc': '宽度适应'},
|
{'attr': BoxFit.fitWidth, 'desc': '等宽'},
|
||||||
{'attr': BoxFit.scaleDown, 'desc': '缩小适应'},
|
{'attr': BoxFit.scaleDown, 'desc': '缩放'},
|
||||||
|
{'attr': BoxFit.none, 'desc': '原始'},
|
||||||
];
|
];
|
||||||
|
|
||||||
PreferredSizeWidget? headerControl;
|
PreferredSizeWidget? headerControl;
|
||||||
@ -827,47 +829,53 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Toggle Change the videofit accordingly
|
/// Toggle Change the videofit accordingly
|
||||||
void toggleVideoFit() {
|
void toggleVideoFit(String toggleType) {
|
||||||
showDialog(
|
if (toggleType == 'press') {
|
||||||
context: Get.context!,
|
final String videoFitDEsc = _videoFitDesc.value;
|
||||||
builder: (context) {
|
final int index = videoFitType.indexWhere(
|
||||||
return AlertDialog(
|
(element) => element['desc'] == videoFitDEsc,
|
||||||
title: const Text('画面比例'),
|
);
|
||||||
content: StatefulBuilder(builder: (context, StateSetter setState) {
|
final int newIndex = index + 1 >= videoFitType.length ? 0 : index + 1;
|
||||||
return Wrap(
|
_videoFit.value = videoFitType[newIndex]['attr'];
|
||||||
alignment: WrapAlignment.start,
|
_videoFitDesc.value = videoFitType[newIndex]['desc'];
|
||||||
|
setVideoFit();
|
||||||
|
SmartDialog.showToast('画面比例:${videoFitType[newIndex]['desc']}');
|
||||||
|
} else {
|
||||||
|
void onPressed(item) {
|
||||||
|
_videoFit.value = item['attr'];
|
||||||
|
_videoFitDesc.value = item['desc'];
|
||||||
|
setVideoFit();
|
||||||
|
Navigator.of(Get.context!).pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('画面比例'),
|
||||||
|
content: Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 2,
|
runSpacing: 2,
|
||||||
children: [
|
children: [
|
||||||
for (var i in videoFitType) ...[
|
for (var i in videoFitType) ...[
|
||||||
if (_videoFit.value == i['attr']) ...[
|
if (_videoFit.value == i['attr']) ...[
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () async {
|
onPressed: () => onPressed(i),
|
||||||
_videoFit.value = i['attr'];
|
|
||||||
_videoFitDesc.value = i['desc'];
|
|
||||||
setVideoFit();
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: Text(i['desc']),
|
child: Text(i['desc']),
|
||||||
),
|
),
|
||||||
] else ...[
|
] else ...[
|
||||||
FilledButton.tonal(
|
FilledButton.tonal(
|
||||||
onPressed: () async {
|
onPressed: () => onPressed(i),
|
||||||
_videoFit.value = i['attr'];
|
|
||||||
_videoFitDesc.value = i['desc'];
|
|
||||||
setVideoFit();
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
child: Text(i['desc']),
|
child: Text(i['desc']),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
);
|
),
|
||||||
}),
|
);
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 缓存fit
|
/// 缓存fit
|
||||||
|
@ -301,16 +301,22 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
/// 画面比例
|
/// 画面比例
|
||||||
BottomControlType.fit: SizedBox(
|
BottomControlType.fit: SizedBox(
|
||||||
|
width: 45,
|
||||||
height: 30,
|
height: 30,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () => _.toggleVideoFit(),
|
onPressed: () => _.toggleVideoFit('press'),
|
||||||
|
onLongPress: () => _.toggleVideoFit('longPress'),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
),
|
),
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
_.videoFitDEsc.value,
|
_.videoFitDEsc.value,
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 13),
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -320,29 +326,49 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
BottomControlType.speed: SizedBox(
|
BottomControlType.speed: SizedBox(
|
||||||
width: 45,
|
width: 45,
|
||||||
height: 34,
|
height: 34,
|
||||||
child: TextButton(
|
child: PopupMenuButton<double>(
|
||||||
style: ButtonStyle(
|
tooltip: '更改播放速度',
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
onSelected: (double value) {
|
||||||
),
|
_.setPlaybackSpeed(value);
|
||||||
onPressed: () {},
|
},
|
||||||
child: Obx(
|
initialValue: _.playbackSpeed,
|
||||||
() => Text(
|
color: Colors.black.withOpacity(0.8),
|
||||||
'${_.playbackSpeed.toString()}X',
|
itemBuilder: (BuildContext context) {
|
||||||
style: textStyle,
|
return _.speedsList.map((double speed) {
|
||||||
|
return PopupMenuItem<double>(
|
||||||
|
height: 40,
|
||||||
|
padding: const EdgeInsets.only(left: 20),
|
||||||
|
value: speed,
|
||||||
|
child: Text(
|
||||||
|
'${speed}x',
|
||||||
|
style: textStyle.copyWith(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 45,
|
||||||
|
height: 34,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
margin: const EdgeInsets.only(right: 4),
|
||||||
|
child: Obx(
|
||||||
|
() => Text(
|
||||||
|
'${_.playbackSpeed.toString()}x',
|
||||||
|
style: textStyle.copyWith(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
/// 字幕
|
|
||||||
/// 全屏
|
/// 全屏
|
||||||
BottomControlType.fullscreen: ComBtn(
|
BottomControlType.fullscreen: ComBtn(
|
||||||
icon: Obx(
|
icon: Obx(
|
||||||
() => Icon(
|
() => Image.asset(
|
||||||
_.isFullScreen.value
|
_.isFullScreen.value
|
||||||
? FontAwesomeIcons.compress
|
? 'assets/images/video/fullscreen_exit.png'
|
||||||
: FontAwesomeIcons.expand,
|
: 'assets/images/video/fullscreen.png',
|
||||||
size: 15,
|
width: 19,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -359,6 +385,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
BottomControlType.time,
|
BottomControlType.time,
|
||||||
BottomControlType.space,
|
BottomControlType.space,
|
||||||
BottomControlType.fit,
|
BottomControlType.fit,
|
||||||
|
BottomControlType.speed,
|
||||||
BottomControlType.fullscreen,
|
BottomControlType.fullscreen,
|
||||||
];
|
];
|
||||||
for (var i = 0; i < userSpecifyItem.length; i++) {
|
for (var i = 0; i < userSpecifyItem.length; i++) {
|
||||||
|
Reference in New Issue
Block a user