mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 重构选集功能,播放器添加选集,修复连播退全屏、无法保存已看完状态
This commit is contained in:
169
lib/common/widgets/list_sheet.dart
Normal file
169
lib/common/widgets/list_sheet.dart
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
|
|
||||||
|
import '../../utils/storage.dart';
|
||||||
|
import '../../utils/utils.dart';
|
||||||
|
|
||||||
|
class ListSheet {
|
||||||
|
final dynamic episodes;
|
||||||
|
final String? bvid;
|
||||||
|
final int? aid;
|
||||||
|
final int currentCid;
|
||||||
|
final Function changeFucCall;
|
||||||
|
final BuildContext context;
|
||||||
|
PersistentBottomSheetController? bottomSheetController;
|
||||||
|
ListSheet({
|
||||||
|
required this.episodes,
|
||||||
|
this.bvid,
|
||||||
|
this.aid,
|
||||||
|
required this.currentCid,
|
||||||
|
required this.changeFucCall,
|
||||||
|
required this.context,
|
||||||
|
});
|
||||||
|
|
||||||
|
Widget buildEpisodeListItem(
|
||||||
|
dynamic episode,
|
||||||
|
int index,
|
||||||
|
bool isCurrentIndex,
|
||||||
|
PersistentBottomSheetController bottomSheetController,
|
||||||
|
) {
|
||||||
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
|
late String title;
|
||||||
|
if (episode.runtimeType.toString() == "EpisodeItem") {
|
||||||
|
if (episode.longTitle != null && episode.longTitle != "") {
|
||||||
|
title = "第${(episode.title ?? '${index + 1}')}话 ${episode.longTitle!}";
|
||||||
|
} else {
|
||||||
|
title = episode.title!;
|
||||||
|
}
|
||||||
|
} else if (episode.runtimeType.toString() == "PageItem") {
|
||||||
|
title = episode.pagePart!;
|
||||||
|
} else if (episode.runtimeType.toString() == "Part") {
|
||||||
|
title = episode.pagePart!;
|
||||||
|
// print("未知类型:${episode.runtimeType}");
|
||||||
|
}
|
||||||
|
return ListTile(
|
||||||
|
onTap: () {
|
||||||
|
if (episode.badge != null && episode.badge == "会员") {
|
||||||
|
dynamic userInfo = GStrorage.userInfo.get('userInfoCache');
|
||||||
|
int vipStatus = 0;
|
||||||
|
if (userInfo != null) {
|
||||||
|
vipStatus = userInfo.vipStatus;
|
||||||
|
}
|
||||||
|
if (vipStatus != 1) {
|
||||||
|
SmartDialog.showToast('需要大会员');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SmartDialog.showToast('切换到:$title');
|
||||||
|
bottomSheetController.close();
|
||||||
|
print(episode.runtimeType.toString());
|
||||||
|
if (episode.runtimeType.toString() == "EpisodeItem") {
|
||||||
|
print(episode.bvid);
|
||||||
|
print(episode.cid);
|
||||||
|
print(episode.aid);
|
||||||
|
changeFucCall(episode.bvid, episode.cid, episode.aid);
|
||||||
|
} else {
|
||||||
|
changeFucCall(bvid!, episode.cid, aid!);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dense: false,
|
||||||
|
leading: isCurrentIndex
|
||||||
|
? Image.asset(
|
||||||
|
'assets/images/live.png',
|
||||||
|
color: primary,
|
||||||
|
height: 12,
|
||||||
|
semanticLabel: "正在播放:",
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: isCurrentIndex
|
||||||
|
? primary
|
||||||
|
: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: episode.badge == null
|
||||||
|
? null
|
||||||
|
: (episode.badge == '会员'
|
||||||
|
? Image.asset(
|
||||||
|
'assets/images/big-vip.png',
|
||||||
|
height: 20,
|
||||||
|
semanticLabel: "大会员",
|
||||||
|
)
|
||||||
|
: Text(episode.badge)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildShowBottomSheet() {
|
||||||
|
int currentIndex =
|
||||||
|
episodes!.indexWhere((dynamic e) => e.cid == currentCid) ?? 0;
|
||||||
|
final ItemScrollController itemScrollController = ItemScrollController();
|
||||||
|
bottomSheetController = showBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
itemScrollController.jumpTo(index: currentIndex);
|
||||||
|
});
|
||||||
|
return Container(
|
||||||
|
height: Utils.getSheetHeight(context),
|
||||||
|
color: Theme.of(context).colorScheme.background,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 45,
|
||||||
|
padding: const EdgeInsets.only(left: 14, right: 14),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'合集(${episodes!.length})',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
tooltip: '关闭',
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () => bottomSheetController!.close(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
color: Theme.of(context).dividerColor.withOpacity(0.1),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Material(
|
||||||
|
child: ScrollablePositionedList.builder(
|
||||||
|
itemCount: episodes!.length + 1,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
bool isLastItem = index == episodes!.length;
|
||||||
|
bool isCurrentIndex = currentIndex == index;
|
||||||
|
return isLastItem
|
||||||
|
? SizedBox(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).padding.bottom + 20,
|
||||||
|
)
|
||||||
|
: buildEpisodeListItem(
|
||||||
|
episodes![index],
|
||||||
|
index,
|
||||||
|
isCurrentIndex,
|
||||||
|
bottomSheetController!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemScrollController: itemScrollController,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -378,6 +378,7 @@ class Part {
|
|||||||
String? weblink;
|
String? weblink;
|
||||||
Dimension? dimension;
|
Dimension? dimension;
|
||||||
String? firstFrame;
|
String? firstFrame;
|
||||||
|
String? badge;
|
||||||
|
|
||||||
Part({
|
Part({
|
||||||
this.cid,
|
this.cid,
|
||||||
@@ -389,6 +390,7 @@ class Part {
|
|||||||
this.weblink,
|
this.weblink,
|
||||||
this.dimension,
|
this.dimension,
|
||||||
this.firstFrame,
|
this.firstFrame,
|
||||||
|
this.badge,
|
||||||
});
|
});
|
||||||
|
|
||||||
fromRawJson(String str) => Part.fromJson(json.decode(str));
|
fromRawJson(String str) => Part.fromJson(json.decode(str));
|
||||||
@@ -407,6 +409,7 @@ class Part {
|
|||||||
? null
|
? null
|
||||||
: Dimension.fromJson(json["dimension"]);
|
: Dimension.fromJson(json["dimension"]);
|
||||||
firstFrame = json["first_frame"];
|
firstFrame = json["first_frame"];
|
||||||
|
badge = json["badge"];
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@@ -420,6 +423,7 @@ class Part {
|
|||||||
data["weblink"] = weblink;
|
data["weblink"] = weblink;
|
||||||
data["dimension"] = dimension?.toJson();
|
data["dimension"] = dimension?.toJson();
|
||||||
data["first_frame"] = firstFrame;
|
data["first_frame"] = firstFrame;
|
||||||
|
data["badge"] = badge;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,9 +631,11 @@ class EpisodeItem {
|
|||||||
this.aid,
|
this.aid,
|
||||||
this.cid,
|
this.cid,
|
||||||
this.title,
|
this.title,
|
||||||
|
this.longTitle,
|
||||||
this.attribute,
|
this.attribute,
|
||||||
this.page,
|
this.page,
|
||||||
this.bvid,
|
this.bvid,
|
||||||
|
this.badge,
|
||||||
});
|
});
|
||||||
int? seasonId;
|
int? seasonId;
|
||||||
int? sectionId;
|
int? sectionId;
|
||||||
@@ -637,9 +643,11 @@ class EpisodeItem {
|
|||||||
int? aid;
|
int? aid;
|
||||||
int? cid;
|
int? cid;
|
||||||
String? title;
|
String? title;
|
||||||
|
String? longTitle;
|
||||||
int? attribute;
|
int? attribute;
|
||||||
Part? page;
|
Part? page;
|
||||||
String? bvid;
|
String? bvid;
|
||||||
|
String? badge;
|
||||||
|
|
||||||
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
EpisodeItem.fromJson(Map<String, dynamic> json) {
|
||||||
seasonId = json['season_id'];
|
seasonId = json['season_id'];
|
||||||
@@ -648,8 +656,10 @@ class EpisodeItem {
|
|||||||
aid = json['aid'];
|
aid = json['aid'];
|
||||||
cid = json['cid'];
|
cid = json['cid'];
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
|
longTitle = json['long_title'];
|
||||||
attribute = json['attribute'];
|
attribute = json['attribute'];
|
||||||
page = Part.fromJson(json['page']);
|
page = Part.fromJson(json['page']);
|
||||||
bvid = json['bvid'];
|
bvid = json['bvid'];
|
||||||
|
badge = json['badge'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 列表循环或者顺序播放时,自动播放下一个
|
/// 列表循环或者顺序播放时,自动播放下一个
|
||||||
void nextPlay() {
|
bool nextPlay() {
|
||||||
late List episodes;
|
late List episodes;
|
||||||
if (bangumiDetail.value.episodes != null) {
|
if (bangumiDetail.value.episodes != null) {
|
||||||
episodes = bangumiDetail.value.episodes!;
|
episodes = bangumiDetail.value.episodes!;
|
||||||
@@ -312,12 +312,15 @@ class BangumiIntroController extends GetxController {
|
|||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextIndex <= episodes.length - 1 &&
|
if (nextIndex == episodes.length - 1 &&
|
||||||
platRepeat == PlayRepeat.listOrder) {}
|
platRepeat == PlayRepeat.listOrder) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int cid = episodes[nextIndex].cid!;
|
int cid = episodes[nextIndex].cid!;
|
||||||
String bvid = episodes[nextIndex].bvid!;
|
String bvid = episodes[nextIndex].bvid!;
|
||||||
int aid = episodes[nextIndex].aid!;
|
int aid = episodes[nextIndex].aid!;
|
||||||
changeSeasonOrbangu(bvid, cid, aid);
|
changeSeasonOrbangu(bvid, cid, aid);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
|||||||
_futureBuilderFuture = bangumiIntroController.queryBangumiIntro();
|
_futureBuilderFuture = bangumiIntroController.queryBangumiIntro();
|
||||||
videoDetailCtr.cid.listen((int p0) {
|
videoDetailCtr.cid.listen((int p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
|
if (!mounted) return;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -138,7 +139,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
print('cid: $cid');
|
print('cid: $cid');
|
||||||
videoDetailCtr.cid.listen((p0) {
|
videoDetailCtr.cid.listen((p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
print('cid: $cid');
|
if (!mounted) return;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -371,8 +372,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
(bangumiItem != null
|
(bangumiItem != null
|
||||||
? bangumiItem!.episodes!.first.cid
|
? bangumiItem!.episodes!.first.cid
|
||||||
: widget.bangumiDetail!.episodes!.first.cid),
|
: widget.bangumiDetail!.episodes!.first.cid),
|
||||||
changeFuc: (bvid, cid, aid) => bangumiIntroController
|
changeFuc: bangumiIntroController.changeSeasonOrbangu,
|
||||||
.changeSeasonOrbangu(bvid, cid, aid),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -6,20 +6,19 @@ import 'package:PiliPalaX/models/bangumi/info.dart';
|
|||||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/list_sheet.dart';
|
||||||
import '../../../utils/utils.dart';
|
|
||||||
|
|
||||||
class BangumiPanel extends StatefulWidget {
|
class BangumiPanel extends StatefulWidget {
|
||||||
const BangumiPanel({
|
const BangumiPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.pages,
|
required this.pages,
|
||||||
this.cid,
|
this.cid,
|
||||||
this.changeFuc,
|
required this.changeFuc,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<EpisodeItem> pages;
|
final List<EpisodeItem> pages;
|
||||||
final int? cid;
|
final int? cid;
|
||||||
final Function? changeFuc;
|
final Function changeFuc;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<BangumiPanel> createState() => _BangumiPanelState();
|
State<BangumiPanel> createState() => _BangumiPanelState();
|
||||||
@@ -52,8 +51,9 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
|
|
||||||
videoDetailCtr.cid.listen((int p0) {
|
videoDetailCtr.cid.listen((int p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
setState(() {});
|
|
||||||
currentIndex = widget.pages.indexWhere((EpisodeItem e) => e.cid == cid);
|
currentIndex = widget.pages.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {});
|
||||||
scrollToIndex();
|
scrollToIndex();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -65,131 +65,20 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPageListItem(
|
// void changeFucCall(item, i) async {
|
||||||
EpisodeItem page,
|
// if (item.badge != null && item.badge == '会员' && vipStatus != 1) {
|
||||||
int index,
|
// SmartDialog.showToast('需要大会员');
|
||||||
bool isCurrentIndex,
|
// return;
|
||||||
) {
|
// }
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
// await widget.changeFuc!(
|
||||||
return ListTile(
|
// item.bvid,
|
||||||
onTap: () {
|
// item.cid,
|
||||||
Get.back();
|
// item.aid,
|
||||||
setState(() {
|
// );
|
||||||
changeFucCall(page, index);
|
// currentIndex = i;
|
||||||
});
|
// setState(() {});
|
||||||
},
|
// scrollToIndex();
|
||||||
dense: false,
|
// }
|
||||||
leading: isCurrentIndex
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/live.png',
|
|
||||||
color: primary,
|
|
||||||
height: 12,
|
|
||||||
semanticLabel: "正在播放:",
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(
|
|
||||||
'第' + (page.title ?? '${index + 1}') + '话 ${page.longTitle!}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: isCurrentIndex
|
|
||||||
? primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: page.badge != null && page.badge == '会员'
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/big-vip.png',
|
|
||||||
height: 20,
|
|
||||||
semanticLabel: "大会员",
|
|
||||||
)
|
|
||||||
: Text(page.badge ?? ""),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showBangumiPanel() {
|
|
||||||
showBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
// await Future.delayed(const Duration(milliseconds: 200));
|
|
||||||
// listViewScrollCtr_2.animateTo(currentIndex * 56,
|
|
||||||
// duration: const Duration(milliseconds: 500),
|
|
||||||
// curve: Curves.easeInOut);
|
|
||||||
itemScrollController.jumpTo(index: currentIndex);
|
|
||||||
});
|
|
||||||
// 在这里使用 setState 更新状态
|
|
||||||
return Container(
|
|
||||||
height: Utils.getSheetHeight(context),
|
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
AppBar(
|
|
||||||
toolbarHeight: 45,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
title: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'合集(${widget.pages.length})',
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: '关闭',
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
titleSpacing: 10,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
|
||||||
child: ScrollablePositionedList.builder(
|
|
||||||
itemCount: widget.pages.length + 1,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
bool isLastItem = index == widget.pages.length;
|
|
||||||
bool isCurrentIndex = currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height:
|
|
||||||
MediaQuery.of(context).padding.bottom +
|
|
||||||
50,
|
|
||||||
)
|
|
||||||
: buildPageListItem(
|
|
||||||
widget.pages[index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemScrollController: itemScrollController,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeFucCall(item, i) async {
|
|
||||||
if (item.badge != null && item.badge == '会员' && vipStatus != 1) {
|
|
||||||
SmartDialog.showToast('需要大会员');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await widget.changeFuc!(
|
|
||||||
item.bvid,
|
|
||||||
item.cid,
|
|
||||||
item.aid,
|
|
||||||
);
|
|
||||||
currentIndex = i;
|
|
||||||
setState(() {});
|
|
||||||
scrollToIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void scrollToIndex() {
|
void scrollToIndex() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
@@ -226,7 +115,16 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
),
|
),
|
||||||
onPressed: () => showBangumiPanel(),
|
onPressed: () {
|
||||||
|
ListSheet(
|
||||||
|
episodes: widget.pages,
|
||||||
|
bvid: widget.pages[currentIndex].bvid!,
|
||||||
|
aid: widget.pages[currentIndex].aid!,
|
||||||
|
currentCid: cid,
|
||||||
|
changeFucCall: widget.changeFuc,
|
||||||
|
context: context)
|
||||||
|
.buildShowBottomSheet();
|
||||||
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'全${widget.pages.length}话',
|
'全${widget.pages.length}话',
|
||||||
style: const TextStyle(fontSize: 13),
|
style: const TextStyle(fontSize: 13),
|
||||||
@@ -252,7 +150,23 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => changeFucCall(widget.pages[i], i),
|
onTap: () {
|
||||||
|
if (widget.pages[i].badge != null &&
|
||||||
|
widget.pages[i].badge == '会员' &&
|
||||||
|
vipStatus != 1) {
|
||||||
|
SmartDialog.showToast('需要大会员');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
widget.changeFuc(
|
||||||
|
widget.pages[i].bvid,
|
||||||
|
widget.pages[i].cid,
|
||||||
|
widget.pages[i].aid,
|
||||||
|
);
|
||||||
|
// currentIndex = i;
|
||||||
|
// setState(() {});
|
||||||
|
// scrollToIndex();
|
||||||
|
},
|
||||||
|
//changeFucCall(widget.pages[i], i),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 8, horizontal: 10),
|
vertical: 8, horizontal: 10),
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 列表循环或者顺序播放时,自动播放下一个
|
/// 列表循环或者顺序播放时,自动播放下一个
|
||||||
void nextPlay() {
|
bool nextPlay() {
|
||||||
final List episodes = [];
|
final List episodes = [];
|
||||||
bool isPages = false;
|
bool isPages = false;
|
||||||
if (videoDetail.value.ugcSeason != null) {
|
if (videoDetail.value.ugcSeason != null) {
|
||||||
@@ -561,13 +561,14 @@ class VideoIntroController extends GetxController {
|
|||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
}
|
}
|
||||||
if (platRepeat == PlayRepeat.listOrder) {
|
if (platRepeat == PlayRepeat.listOrder) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final int cid = episodes[nextIndex].cid!;
|
final int cid = episodes[nextIndex].cid!;
|
||||||
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
||||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
||||||
changeSeasonOrbangu(rBvid, cid, rAid);
|
changeSeasonOrbangu(rBvid, cid, rAid);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置关注分组
|
// 设置关注分组
|
||||||
|
|||||||
@@ -374,8 +374,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
cid: videoIntroController.lastPlayCid.value != 0
|
cid: videoIntroController.lastPlayCid.value != 0
|
||||||
? videoIntroController.lastPlayCid.value
|
? videoIntroController.lastPlayCid.value
|
||||||
: widget.videoDetail!.pages!.first.cid,
|
: widget.videoDetail!.pages!.first.cid,
|
||||||
changeFuc: (bvid, cid, aid) => videoIntroController
|
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||||
.changeSeasonOrbangu(bvid, cid, aid),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -385,11 +384,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(() => PagesPanel(
|
Obx(() => PagesPanel(
|
||||||
pages: widget.videoDetail!.pages!,
|
pages: widget.videoDetail!.pages!,
|
||||||
cid: videoIntroController.lastPlayCid.value,
|
cid: videoIntroController.lastPlayCid.value,
|
||||||
changeFuc: (cid) =>
|
bvid: videoIntroController.bvid,
|
||||||
videoIntroController.changeSeasonOrbangu(
|
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||||
videoIntroController.bvid,
|
|
||||||
cid,
|
|
||||||
IdUtils.bv2av(videoIntroController.bvid)),
|
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:PiliPalaX/common/widgets/list_sheet.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||||
|
|
||||||
import '../../../../../utils/utils.dart';
|
import '../../../../../utils/id_utils.dart';
|
||||||
|
|
||||||
class PagesPanel extends StatefulWidget {
|
class PagesPanel extends StatefulWidget {
|
||||||
const PagesPanel({
|
const PagesPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.pages,
|
required this.pages,
|
||||||
this.cid,
|
this.cid,
|
||||||
this.changeFuc,
|
required this.bvid,
|
||||||
|
required this.changeFuc,
|
||||||
});
|
});
|
||||||
final List<Part> pages;
|
final List<Part> pages;
|
||||||
final int? cid;
|
final int? cid;
|
||||||
final Function? changeFuc;
|
final String bvid;
|
||||||
|
final Function changeFuc;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PagesPanel> createState() => _PagesPanelState();
|
State<PagesPanel> createState() => _PagesPanelState();
|
||||||
@@ -28,7 +31,6 @@ class _PagesPanelState extends State<PagesPanel> {
|
|||||||
late int currentIndex;
|
late int currentIndex;
|
||||||
final String heroTag = Get.arguments['heroTag'];
|
final String heroTag = Get.arguments['heroTag'];
|
||||||
late VideoDetailController _videoDetailController;
|
late VideoDetailController _videoDetailController;
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
final ScrollController _scrollController2 = ScrollController();
|
final ScrollController _scrollController2 = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -40,66 +42,27 @@ class _PagesPanelState extends State<PagesPanel> {
|
|||||||
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
||||||
_videoDetailController.cid.listen((int p0) {
|
_videoDetailController.cid.listen((int p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
setState(() {});
|
|
||||||
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
||||||
|
if (!mounted) return;
|
||||||
|
const double itemWidth = 150; // 每个列表项的宽度
|
||||||
|
final double targetOffset = min(
|
||||||
|
(currentIndex * itemWidth) - (itemWidth / 2),
|
||||||
|
_scrollController2.position.maxScrollExtent);
|
||||||
|
// 滑动至目标位置
|
||||||
|
_scrollController2.animateTo(
|
||||||
|
targetOffset,
|
||||||
|
duration: const Duration(milliseconds: 300), // 滑动动画持续时间
|
||||||
|
curve: Curves.easeInOut, // 滑动动画曲线
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeFucCall(item, i) async {
|
|
||||||
await widget.changeFuc!(item.cid);
|
|
||||||
|
|
||||||
const double itemWidth = 150; // 每个列表项的宽度
|
|
||||||
final double targetOffset = min((i * itemWidth) - (itemWidth / 2),
|
|
||||||
_scrollController2.position.maxScrollExtent);
|
|
||||||
|
|
||||||
// 滑动至目标位置
|
|
||||||
_scrollController2.animateTo(
|
|
||||||
targetOffset,
|
|
||||||
duration: const Duration(milliseconds: 300), // 滑动动画持续时间
|
|
||||||
curve: Curves.easeInOut, // 滑动动画曲线
|
|
||||||
);
|
|
||||||
currentIndex = i;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_scrollController.dispose();
|
_scrollController2.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildEpisodeListItem(
|
|
||||||
Part episode,
|
|
||||||
int index,
|
|
||||||
bool isCurrentIndex,
|
|
||||||
) {
|
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
|
||||||
return ListTile(
|
|
||||||
onTap: () {
|
|
||||||
changeFucCall(episode, index);
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
dense: false,
|
|
||||||
leading: isCurrentIndex
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/live.png',
|
|
||||||
color: primary,
|
|
||||||
height: 12,
|
|
||||||
semanticLabel: "正在播放:",
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(
|
|
||||||
episode.pagePart!,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: isCurrentIndex
|
|
||||||
? primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
@@ -128,83 +91,14 @@ class _PagesPanelState extends State<PagesPanel> {
|
|||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showBottomSheet(
|
ListSheet(
|
||||||
|
episodes: episodes,
|
||||||
|
bvid: widget.bvid,
|
||||||
|
aid: IdUtils.bv2av(widget.bvid),
|
||||||
|
currentCid: cid,
|
||||||
|
changeFucCall: widget.changeFuc,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
).buildShowBottomSheet();
|
||||||
return StatefulBuilder(builder:
|
|
||||||
(BuildContext context, StateSetter setState) {
|
|
||||||
WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) async {
|
|
||||||
await Future.delayed(
|
|
||||||
const Duration(milliseconds: 200));
|
|
||||||
_scrollController.jumpTo(currentIndex * 56);
|
|
||||||
});
|
|
||||||
return Container(
|
|
||||||
height: Utils.getSheetHeight(context),
|
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 45,
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 14, right: 14),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'合集(${episodes.length})',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: '关闭',
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
height: 1,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.dividerColor
|
|
||||||
.withOpacity(0.1),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
|
||||||
child: ListView.builder(
|
|
||||||
controller: _scrollController,
|
|
||||||
itemCount: episodes.length + 1,
|
|
||||||
itemBuilder:
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
bool isLastItem =
|
|
||||||
index == episodes.length;
|
|
||||||
bool isCurrentIndex =
|
|
||||||
currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height: MediaQuery.of(context)
|
|
||||||
.padding
|
|
||||||
.bottom +
|
|
||||||
20,
|
|
||||||
)
|
|
||||||
: buildEpisodeListItem(
|
|
||||||
episodes[index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'共${widget.pages.length}集',
|
'共${widget.pages.length}集',
|
||||||
@@ -233,7 +127,10 @@ class _PagesPanelState extends State<PagesPanel> {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => changeFucCall(widget.pages[i], i),
|
onTap: () => {
|
||||||
|
widget.changeFuc(widget.bvid, widget.pages[i].cid,
|
||||||
|
IdUtils.bv2av(widget.bvid))
|
||||||
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 8, horizontal: 8),
|
vertical: 8, horizontal: 8),
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
|
import 'package:PiliPalaX/common/widgets/list_sheet.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|
||||||
|
|
||||||
import '../../../../../utils/utils.dart';
|
|
||||||
|
|
||||||
class SeasonPanel extends StatefulWidget {
|
class SeasonPanel extends StatefulWidget {
|
||||||
const SeasonPanel({
|
const SeasonPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.ugcSeason,
|
required this.ugcSeason,
|
||||||
this.cid,
|
this.cid,
|
||||||
this.changeFuc,
|
required this.changeFuc,
|
||||||
});
|
});
|
||||||
final UgcSeason ugcSeason;
|
final UgcSeason ugcSeason;
|
||||||
final int? cid;
|
final int? cid;
|
||||||
final Function? changeFuc;
|
final Function changeFuc;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SeasonPanel> createState() => _SeasonPanelState();
|
State<SeasonPanel> createState() => _SeasonPanelState();
|
||||||
@@ -30,7 +27,6 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
final String heroTag = Get.arguments['heroTag'];
|
final String heroTag = Get.arguments['heroTag'];
|
||||||
late VideoDetailController _videoDetailController;
|
late VideoDetailController _videoDetailController;
|
||||||
final ScrollController _scrollController = ScrollController();
|
final ScrollController _scrollController = ScrollController();
|
||||||
final ItemScrollController itemScrollController = ItemScrollController();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -62,21 +58,22 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
|
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
_videoDetailController.cid.listen((int p0) {
|
_videoDetailController.cid.listen((int p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
setState(() {});
|
|
||||||
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
|
currentIndex = episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeFucCall(item, int i) async {
|
// void changeFucCall(item, int i) async {
|
||||||
await widget.changeFuc!(
|
// await widget.changeFuc!(
|
||||||
IdUtils.av2bv(item.aid),
|
// IdUtils.av2bv(item.aid),
|
||||||
item.cid,
|
// item.cid,
|
||||||
item.aid,
|
// item.aid,
|
||||||
);
|
// );
|
||||||
currentIndex = i;
|
// currentIndex = i;
|
||||||
Get.back();
|
// Get.back();
|
||||||
setState(() {});
|
// setState(() {});
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -84,35 +81,6 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildEpisodeListItem(
|
|
||||||
EpisodeItem episode,
|
|
||||||
int index,
|
|
||||||
bool isCurrentIndex,
|
|
||||||
) {
|
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
|
||||||
return ListTile(
|
|
||||||
onTap: () => changeFucCall(episode, index),
|
|
||||||
dense: false,
|
|
||||||
leading: isCurrentIndex
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/live.png',
|
|
||||||
color: primary,
|
|
||||||
height: 12,
|
|
||||||
semanticLabel: "正在播放:",
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(
|
|
||||||
episode.title!,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: isCurrentIndex
|
|
||||||
? primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (episodes == null) {
|
if (episodes == null) {
|
||||||
@@ -131,75 +99,16 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => showBottomSheet(
|
onTap: () {
|
||||||
context: context,
|
ListSheet(
|
||||||
builder: (BuildContext context) {
|
episodes: episodes,
|
||||||
return StatefulBuilder(
|
// bvid: IdUtils.av2bv(episodes!.first.aid!),
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
// aid: episodes!.first.aid!,
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
currentCid: cid,
|
||||||
itemScrollController.jumpTo(index: currentIndex);
|
changeFucCall: widget.changeFuc,
|
||||||
});
|
context: context)
|
||||||
return Container(
|
.buildShowBottomSheet();
|
||||||
height: Utils.getSheetHeight(context),
|
},
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 45,
|
|
||||||
padding: const EdgeInsets.only(left: 14, right: 14),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'合集(${episodes!.length})',
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
tooltip: '关闭',
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
height: 1,
|
|
||||||
color:
|
|
||||||
Theme.of(context).dividerColor.withOpacity(0.1),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.of(context).padding.bottom),
|
|
||||||
child: Material(
|
|
||||||
child: ScrollablePositionedList.builder(
|
|
||||||
itemCount: episodes!.length + 1,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
bool isLastItem = index == episodes!.length;
|
|
||||||
bool isCurrentIndex = currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height: MediaQuery.of(context)
|
|
||||||
.padding
|
|
||||||
.bottom +
|
|
||||||
20,
|
|
||||||
)
|
|
||||||
: buildEpisodeListItem(
|
|
||||||
episodes![index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemScrollController: itemScrollController,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
|
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -146,28 +146,30 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
void playerListener(PlayerStatus? status) async {
|
void playerListener(PlayerStatus? status) async {
|
||||||
playerStatus = status!;
|
playerStatus = status!;
|
||||||
if (status == PlayerStatus.completed) {
|
if (status == PlayerStatus.completed) {
|
||||||
// 结束播放退出全屏
|
|
||||||
if (autoExitFullcreen) {
|
|
||||||
plPlayerController!.triggerFullScreen(status: false);
|
|
||||||
}
|
|
||||||
shutdownTimerService.handleWaitingFinished();
|
shutdownTimerService.handleWaitingFinished();
|
||||||
|
bool notExitFlag = false;
|
||||||
/// 顺序播放 列表循环
|
/// 顺序播放 列表循环
|
||||||
if (plPlayerController!.playRepeat != PlayRepeat.pause &&
|
if (plPlayerController!.playRepeat != PlayRepeat.pause &&
|
||||||
plPlayerController!.playRepeat != PlayRepeat.singleCycle) {
|
plPlayerController!.playRepeat != PlayRepeat.singleCycle) {
|
||||||
if (videoDetailController.videoType == SearchType.video) {
|
if (videoDetailController.videoType == SearchType.video) {
|
||||||
videoIntroController.nextPlay();
|
notExitFlag = videoIntroController.nextPlay();
|
||||||
}
|
}
|
||||||
if (videoDetailController.videoType == SearchType.media_bangumi) {
|
if (videoDetailController.videoType == SearchType.media_bangumi) {
|
||||||
bangumiIntroController.nextPlay();
|
notExitFlag = bangumiIntroController.nextPlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 单个循环
|
/// 单个循环
|
||||||
if (plPlayerController!.playRepeat == PlayRepeat.singleCycle) {
|
if (plPlayerController!.playRepeat == PlayRepeat.singleCycle) {
|
||||||
|
notExitFlag = true;
|
||||||
plPlayerController!.seekTo(Duration.zero);
|
plPlayerController!.seekTo(Duration.zero);
|
||||||
plPlayerController!.play();
|
plPlayerController!.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 结束播放退出全屏
|
||||||
|
if (!notExitFlag && autoExitFullcreen) {
|
||||||
|
plPlayerController!.triggerFullScreen(status: false);
|
||||||
|
}
|
||||||
// 播放完展示控制栏
|
// 播放完展示控制栏
|
||||||
if (videoDetailController.floating != null) {
|
if (videoDetailController.floating != null) {
|
||||||
PiPStatus currentStatus =
|
PiPStatus currentStatus =
|
||||||
@@ -263,6 +265,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// 离开当前页面时
|
// 离开当前页面时
|
||||||
void didPushNext() async {
|
void didPushNext() async {
|
||||||
_bufferedListener?.cancel();
|
_bufferedListener?.cancel();
|
||||||
|
|
||||||
/// 开启
|
/// 开启
|
||||||
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
|
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
|
||||||
as bool) {
|
as bool) {
|
||||||
@@ -449,6 +452,19 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
: PLVideoPlayer(
|
: PLVideoPlayer(
|
||||||
controller:
|
controller:
|
||||||
plPlayerController!,
|
plPlayerController!,
|
||||||
|
videoIntroController:
|
||||||
|
videoDetailController
|
||||||
|
.videoType ==
|
||||||
|
SearchType.video
|
||||||
|
? videoIntroController
|
||||||
|
: null,
|
||||||
|
bangumiIntroController:
|
||||||
|
videoDetailController
|
||||||
|
.videoType ==
|
||||||
|
SearchType
|
||||||
|
.media_bangumi
|
||||||
|
? bangumiIntroController
|
||||||
|
: null,
|
||||||
headerControl:
|
headerControl:
|
||||||
videoDetailController
|
videoDetailController
|
||||||
.headerControl,
|
.headerControl,
|
||||||
@@ -702,6 +718,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
: PLVideoPlayer(
|
: PLVideoPlayer(
|
||||||
controller:
|
controller:
|
||||||
plPlayerController!,
|
plPlayerController!,
|
||||||
|
videoIntroController:
|
||||||
|
videoDetailController
|
||||||
|
.videoType ==
|
||||||
|
SearchType
|
||||||
|
.video
|
||||||
|
? videoIntroController
|
||||||
|
: null,
|
||||||
|
bangumiIntroController:
|
||||||
|
videoDetailController
|
||||||
|
.videoType ==
|
||||||
|
SearchType
|
||||||
|
.media_bangumi
|
||||||
|
? bangumiIntroController
|
||||||
|
: null,
|
||||||
headerControl:
|
headerControl:
|
||||||
videoDetailController
|
videoDetailController
|
||||||
.headerControl,
|
.headerControl,
|
||||||
@@ -875,6 +905,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
: PLVideoPlayer(
|
: PLVideoPlayer(
|
||||||
controller: plPlayerController!,
|
controller: plPlayerController!,
|
||||||
|
videoIntroController:
|
||||||
|
videoDetailController.videoType == SearchType.video
|
||||||
|
? videoIntroController
|
||||||
|
: null,
|
||||||
|
bangumiIntroController:
|
||||||
|
videoDetailController.videoType == SearchType.media_bangumi
|
||||||
|
? bangumiIntroController
|
||||||
|
: null,
|
||||||
headerControl: HeaderControl(
|
headerControl: HeaderControl(
|
||||||
controller: plPlayerController,
|
controller: plPlayerController,
|
||||||
videoDetailCtr: videoDetailController,
|
videoDetailCtr: videoDetailController,
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class PlPlayerController {
|
|||||||
final Rx<String> _videoFitDesc = Rx(videoFitType.first['desc']);
|
final Rx<String> _videoFitDesc = Rx(videoFitType.first['desc']);
|
||||||
late StreamSubscription<DataStatus> _dataListenerForVideoFit;
|
late StreamSubscription<DataStatus> _dataListenerForVideoFit;
|
||||||
late StreamSubscription<DataStatus> _dataListenerForEnterFullscreen;
|
late StreamSubscription<DataStatus> _dataListenerForEnterFullscreen;
|
||||||
|
|
||||||
/// 后台播放
|
/// 后台播放
|
||||||
final Rx<bool> _backgroundPlay = false.obs;
|
final Rx<bool> _backgroundPlay = false.obs;
|
||||||
|
|
||||||
@@ -126,6 +127,9 @@ class PlPlayerController {
|
|||||||
PreferredSizeWidget? bottomControl;
|
PreferredSizeWidget? bottomControl;
|
||||||
Widget? danmuWidget;
|
Widget? danmuWidget;
|
||||||
|
|
||||||
|
String get bvid => _bvid;
|
||||||
|
int get cid => _cid;
|
||||||
|
|
||||||
/// 数据加载监听
|
/// 数据加载监听
|
||||||
Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream;
|
Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream;
|
||||||
|
|
||||||
@@ -620,7 +624,7 @@ class PlPlayerController {
|
|||||||
} else {
|
} else {
|
||||||
// playerStatus.status.value = PlayerStatus.playing;
|
// playerStatus.status.value = PlayerStatus.playing;
|
||||||
}
|
}
|
||||||
makeHeartBeat(positionSeconds.value, type: 'status');
|
makeHeartBeat(positionSeconds.value, type: 'completed');
|
||||||
}),
|
}),
|
||||||
videoPlayerController!.stream.position.listen((event) {
|
videoPlayerController!.stream.position.listen((event) {
|
||||||
_position.value = event;
|
_position.value = event;
|
||||||
@@ -1100,15 +1104,17 @@ class PlPlayerController {
|
|||||||
if (videoType.value == 'live') {
|
if (videoType.value == 'live') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool isComplete = playerStatus.status.value == PlayerStatus.completed ||
|
||||||
|
type == 'completed';
|
||||||
// 播放状态变化时,更新
|
// 播放状态变化时,更新
|
||||||
if (type == 'status') {
|
if (type == 'status' || type == 'completed') {
|
||||||
await VideoHttp.heartBeat(
|
await VideoHttp.heartBeat(
|
||||||
bvid: _bvid,
|
bvid: _bvid,
|
||||||
cid: _cid,
|
cid: _cid,
|
||||||
progress:
|
progress: isComplete ? -1 : progress,
|
||||||
playerStatus.status.value == PlayerStatus.completed ? -1 : progress,
|
|
||||||
);
|
);
|
||||||
} else
|
return;
|
||||||
|
}
|
||||||
// 正常播放时,间隔5秒更新一次
|
// 正常播放时,间隔5秒更新一次
|
||||||
if (progress - _heartDuration >= 5) {
|
if (progress - _heartDuration >= 5) {
|
||||||
_heartDuration = progress;
|
_heartDuration = progress;
|
||||||
|
|||||||
12
lib/plugin/pl_player/models/bottom_control_type.dart
Normal file
12
lib/plugin/pl_player/models/bottom_control_type.dart
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
enum BottomControlType {
|
||||||
|
pre,
|
||||||
|
playOrPause,
|
||||||
|
next,
|
||||||
|
time,
|
||||||
|
space,
|
||||||
|
episode,
|
||||||
|
fit,
|
||||||
|
subtitle,
|
||||||
|
speed,
|
||||||
|
fullscreen,
|
||||||
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:PiliPalaX/pages/video/detail/introduction/controller.dart';
|
||||||
|
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
|
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
|
||||||
@@ -8,37 +11,48 @@ import 'package:get/get.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:media_kit/media_kit.dart';
|
import 'package:media_kit/media_kit.dart';
|
||||||
import 'package:media_kit_video/media_kit_video.dart';
|
import 'package:media_kit_video/media_kit_video.dart';
|
||||||
import 'package:nil/nil.dart';
|
|
||||||
import 'package:PiliPalaX/plugin/pl_player/controller.dart';
|
import 'package:PiliPalaX/plugin/pl_player/controller.dart';
|
||||||
import 'package:PiliPalaX/plugin/pl_player/models/duration.dart';
|
import 'package:PiliPalaX/plugin/pl_player/models/duration.dart';
|
||||||
import 'package:PiliPalaX/plugin/pl_player/models/fullscreen_mode.dart';
|
import 'package:PiliPalaX/plugin/pl_player/models/fullscreen_mode.dart';
|
||||||
import 'package:PiliPalaX/plugin/pl_player/utils.dart';
|
import 'package:PiliPalaX/plugin/pl_player/utils.dart';
|
||||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
|
import 'package:media_kit_video/media_kit_video_controls/src/controls/methods/video_state.dart';
|
||||||
import 'package:screen_brightness/screen_brightness.dart';
|
import 'package:screen_brightness/screen_brightness.dart';
|
||||||
|
|
||||||
import '../../common/widgets/audio_video_progress_bar.dart';
|
import '../../common/widgets/audio_video_progress_bar.dart';
|
||||||
|
import '../../models/video_detail_res.dart';
|
||||||
|
import '../../pages/bangumi/introduction/controller.dart';
|
||||||
|
import '../../common/widgets/list_sheet.dart';
|
||||||
import '../../utils/utils.dart';
|
import '../../utils/utils.dart';
|
||||||
|
import 'models/bottom_control_type.dart';
|
||||||
import 'models/bottom_progress_behavior.dart';
|
import 'models/bottom_progress_behavior.dart';
|
||||||
import 'widgets/app_bar_ani.dart';
|
import 'widgets/app_bar_ani.dart';
|
||||||
import 'widgets/backward_seek.dart';
|
import 'widgets/backward_seek.dart';
|
||||||
import 'widgets/bottom_control.dart';
|
import 'widgets/bottom_control.dart';
|
||||||
import 'widgets/common_btn.dart';
|
import 'widgets/common_btn.dart';
|
||||||
import 'widgets/forward_seek.dart';
|
import 'widgets/forward_seek.dart';
|
||||||
|
import 'widgets/play_pause_btn.dart';
|
||||||
|
|
||||||
class PLVideoPlayer extends StatefulWidget {
|
class PLVideoPlayer extends StatefulWidget {
|
||||||
const PLVideoPlayer({
|
const PLVideoPlayer({
|
||||||
required this.controller,
|
required this.controller,
|
||||||
|
this.videoIntroController,
|
||||||
|
this.bangumiIntroController,
|
||||||
this.headerControl,
|
this.headerControl,
|
||||||
this.bottomControl,
|
this.bottomControl,
|
||||||
this.danmuWidget,
|
this.danmuWidget,
|
||||||
|
this.bottomList,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final PlPlayerController controller;
|
final PlPlayerController controller;
|
||||||
|
final VideoIntroController? videoIntroController;
|
||||||
|
final BangumiIntroController? bangumiIntroController;
|
||||||
final PreferredSizeWidget? headerControl;
|
final PreferredSizeWidget? headerControl;
|
||||||
final PreferredSizeWidget? bottomControl;
|
final PreferredSizeWidget? bottomControl;
|
||||||
final Widget? danmuWidget;
|
final Widget? danmuWidget;
|
||||||
|
final List<BottomControlType>? bottomList;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
|
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
|
||||||
@@ -48,27 +62,25 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
with TickerProviderStateMixin {
|
with TickerProviderStateMixin {
|
||||||
late AnimationController animationController;
|
late AnimationController animationController;
|
||||||
late VideoController videoController;
|
late VideoController videoController;
|
||||||
final PLVideoPlayerController _ctr = Get.put(PLVideoPlayerController());
|
late VideoIntroController? videoIntroController;
|
||||||
|
late BangumiIntroController? bangumiIntroController;
|
||||||
|
|
||||||
final GlobalKey _playerKey = GlobalKey();
|
final GlobalKey _playerKey = GlobalKey();
|
||||||
// bool _mountSeekBackwardButton = false;
|
final RxBool _mountSeekBackwardButton = false.obs;
|
||||||
// bool _mountSeekForwardButton = false;
|
final RxBool _mountSeekForwardButton = false.obs;
|
||||||
// bool _hideSeekBackwardButton = false;
|
final RxBool _hideSeekBackwardButton = false.obs;
|
||||||
// bool _hideSeekForwardButton = false;
|
final RxBool _hideSeekForwardButton = false.obs;
|
||||||
|
|
||||||
// double _brightnessValue = 0.0;
|
final RxDouble _brightnessValue = 0.0.obs;
|
||||||
// bool _brightnessIndicator = false;
|
final RxBool _brightnessIndicator = false.obs;
|
||||||
Timer? _brightnessTimer;
|
Timer? _brightnessTimer;
|
||||||
|
|
||||||
// double _volumeValue = 0.0;
|
final RxDouble _volumeValue = 0.0.obs;
|
||||||
// bool _volumeIndicator = false;
|
final RxBool _volumeIndicator = false.obs;
|
||||||
Timer? _volumeTimer;
|
Timer? _volumeTimer;
|
||||||
|
|
||||||
double _distance = 0.0;
|
final RxDouble _distance = 0.0.obs;
|
||||||
// 初始手指落下位置
|
final RxBool _volumeInterceptEventStream = false.obs;
|
||||||
// double _initTapPositoin = 0.0;
|
|
||||||
|
|
||||||
// bool _volumeInterceptEventStream = false;
|
|
||||||
|
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
late FullScreenMode mode;
|
late FullScreenMode mode;
|
||||||
@@ -87,11 +99,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
double _lastAnnouncedValue = -1;
|
double _lastAnnouncedValue = -1;
|
||||||
|
|
||||||
void onDoubleTapSeekBackward() {
|
void onDoubleTapSeekBackward() {
|
||||||
_ctr.onDoubleTapSeekBackward();
|
_mountSeekBackwardButton.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDoubleTapSeekForward() {
|
void onDoubleTapSeekForward() {
|
||||||
_ctr.onDoubleTapSeekForward();
|
_mountSeekForwardButton.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 双击播放、暂停
|
// 双击播放、暂停
|
||||||
@@ -126,6 +138,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
animationController = AnimationController(
|
animationController = AnimationController(
|
||||||
vsync: this, duration: const Duration(milliseconds: 100));
|
vsync: this, duration: const Duration(milliseconds: 100));
|
||||||
videoController = widget.controller.videoController!;
|
videoController = widget.controller.videoController!;
|
||||||
|
videoIntroController = widget.videoIntroController;
|
||||||
|
bangumiIntroController = widget.bangumiIntroController;
|
||||||
widget.controller.headerControl = widget.headerControl;
|
widget.controller.headerControl = widget.headerControl;
|
||||||
widget.controller.bottomControl = widget.bottomControl;
|
widget.controller.bottomControl = widget.bottomControl;
|
||||||
widget.controller.danmuWidget = widget.danmuWidget;
|
widget.controller.danmuWidget = widget.danmuWidget;
|
||||||
@@ -138,10 +152,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Future.microtask(() async {
|
Future.microtask(() async {
|
||||||
try {
|
try {
|
||||||
FlutterVolumeController.updateShowSystemUI(true);
|
FlutterVolumeController.updateShowSystemUI(true);
|
||||||
_ctr.volumeValue.value = (await FlutterVolumeController.getVolume())!;
|
_volumeValue.value = (await FlutterVolumeController.getVolume())!;
|
||||||
FlutterVolumeController.addListener((double value) {
|
FlutterVolumeController.addListener((double value) {
|
||||||
if (mounted && !_ctr.volumeInterceptEventStream.value) {
|
if (mounted && !_volumeInterceptEventStream.value) {
|
||||||
_ctr.volumeValue.value = value;
|
_volumeValue.value = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@@ -149,10 +163,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
Future.microtask(() async {
|
Future.microtask(() async {
|
||||||
try {
|
try {
|
||||||
_ctr.brightnessValue.value = await ScreenBrightness().current;
|
_brightnessValue.value = await ScreenBrightness().current;
|
||||||
ScreenBrightness().onCurrentBrightnessChanged.listen((double value) {
|
ScreenBrightness().onCurrentBrightnessChanged.listen((double value) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
_ctr.brightnessValue.value = value;
|
_brightnessValue.value = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
@@ -164,14 +178,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
FlutterVolumeController.updateShowSystemUI(false);
|
FlutterVolumeController.updateShowSystemUI(false);
|
||||||
await FlutterVolumeController.setVolume(value);
|
await FlutterVolumeController.setVolume(value);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
_ctr.volumeValue.value = value;
|
_volumeValue.value = value;
|
||||||
_ctr.volumeIndicator.value = true;
|
_volumeIndicator.value = true;
|
||||||
_ctr.volumeInterceptEventStream.value = true;
|
_volumeInterceptEventStream.value = true;
|
||||||
_volumeTimer?.cancel();
|
_volumeTimer?.cancel();
|
||||||
_volumeTimer = Timer(const Duration(milliseconds: 200), () {
|
_volumeTimer = Timer(const Duration(milliseconds: 200), () {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
_ctr.volumeIndicator.value = false;
|
_volumeIndicator.value = false;
|
||||||
_ctr.volumeInterceptEventStream.value = false;
|
_volumeInterceptEventStream.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -180,11 +194,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
try {
|
try {
|
||||||
await ScreenBrightness().setScreenBrightness(value);
|
await ScreenBrightness().setScreenBrightness(value);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
_ctr.brightnessIndicator.value = true;
|
_brightnessIndicator.value = true;
|
||||||
_brightnessTimer?.cancel();
|
_brightnessTimer?.cancel();
|
||||||
_brightnessTimer = Timer(const Duration(milliseconds: 200), () {
|
_brightnessTimer = Timer(const Duration(milliseconds: 200), () {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
_ctr.brightnessIndicator.value = false;
|
_brightnessIndicator.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
widget.controller.brightness.value = value;
|
widget.controller.brightness.value = value;
|
||||||
@@ -197,6 +211,268 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 动态构建底部控制条
|
||||||
|
List<Widget> buildBottomControl() {
|
||||||
|
final PlPlayerController _ = widget.controller;
|
||||||
|
Map<BottomControlType, Widget> videoProgressWidgets = {
|
||||||
|
/// 上一集
|
||||||
|
BottomControlType.pre: ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.skip_previous,
|
||||||
|
size: 15,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: () {},
|
||||||
|
tooltip: '上一集',
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 播放暂停
|
||||||
|
BottomControlType.playOrPause: PlayOrPauseButton(
|
||||||
|
controller: _,
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 下一集
|
||||||
|
BottomControlType.next: ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.skip_next,
|
||||||
|
size: 15,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: () {},
|
||||||
|
tooltip: '下一集',
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 时间进度
|
||||||
|
BottomControlType.time: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// 播放时间
|
||||||
|
Obx(() {
|
||||||
|
return Text(
|
||||||
|
Utils.timeFormat(_.positionSeconds.value),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 10,
|
||||||
|
height: 1.4,
|
||||||
|
fontFeatures: [FontFeature.tabularFigures()],
|
||||||
|
),
|
||||||
|
semanticsLabel:
|
||||||
|
'已播放${Utils.durationReadFormat(Utils.timeFormat(_.positionSeconds.value))}',
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
// const SizedBox(width: 2),
|
||||||
|
// const ExcludeSemantics(
|
||||||
|
// child: Text(
|
||||||
|
// '/',
|
||||||
|
// style: textStyle,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(width: 2),
|
||||||
|
Obx(
|
||||||
|
() => Text(
|
||||||
|
Utils.timeFormat(_.durationSeconds.value),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Color(0xFFD0D0D0),
|
||||||
|
fontSize: 10,
|
||||||
|
height: 1.4,
|
||||||
|
fontFeatures: [FontFeature.tabularFigures()],
|
||||||
|
),
|
||||||
|
semanticsLabel:
|
||||||
|
'共${Utils.durationReadFormat(Utils.timeFormat(_.durationSeconds.value))}',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 空白占位
|
||||||
|
BottomControlType.space: const Spacer(),
|
||||||
|
|
||||||
|
/// 选集
|
||||||
|
BottomControlType.episode: Obx(() {
|
||||||
|
bool isSeason =
|
||||||
|
videoIntroController?.videoDetail.value.ugcSeason != null;
|
||||||
|
bool isPage = videoIntroController?.videoDetail.value.pages != null &&
|
||||||
|
videoIntroController!.videoDetail.value.pages!.length > 1;
|
||||||
|
bool isBangumi = bangumiIntroController?.bangumiDetail.value != null;
|
||||||
|
if (!isSeason && !isPage && !isBangumi) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
return SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
child: Container(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.list,
|
||||||
|
size: 22,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
tooltip: '选集',
|
||||||
|
fuc: () {
|
||||||
|
int currentCid = widget.controller.cid;
|
||||||
|
String bvid = widget.controller.bvid;
|
||||||
|
final List episodes = [];
|
||||||
|
late Function changeFucCall;
|
||||||
|
if (isSeason) {
|
||||||
|
final List<SectionItem> sections = videoIntroController!
|
||||||
|
.videoDetail.value.ugcSeason!.sections!;
|
||||||
|
for (int i = 0; i < sections.length; i++) {
|
||||||
|
final List<EpisodeItem> episodesList =
|
||||||
|
sections[i].episodes!;
|
||||||
|
episodes.addAll(episodesList);
|
||||||
|
}
|
||||||
|
changeFucCall = videoIntroController!.changeSeasonOrbangu;
|
||||||
|
} else if (isPage) {
|
||||||
|
final List<Part> pages =
|
||||||
|
videoIntroController!.videoDetail.value.pages!;
|
||||||
|
episodes.addAll(pages);
|
||||||
|
changeFucCall = videoIntroController!.changeSeasonOrbangu;
|
||||||
|
} else if (isBangumi) {
|
||||||
|
episodes.addAll(bangumiIntroController!.bangumiDetail.value.episodes!);
|
||||||
|
changeFucCall = bangumiIntroController!.changeSeasonOrbangu;
|
||||||
|
}
|
||||||
|
ListSheet(
|
||||||
|
episodes: episodes,
|
||||||
|
bvid: bvid,
|
||||||
|
aid: IdUtils.bv2av(bvid),
|
||||||
|
currentCid: currentCid,
|
||||||
|
changeFucCall: changeFucCall,
|
||||||
|
context: context,
|
||||||
|
).buildShowBottomSheet();
|
||||||
|
},
|
||||||
|
)));
|
||||||
|
}),
|
||||||
|
|
||||||
|
/// 画面比例
|
||||||
|
BottomControlType.fit: SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () => _.toggleVideoFit(),
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
|
),
|
||||||
|
child: Obx(
|
||||||
|
() => Text(
|
||||||
|
_.videoFitDEsc.value,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 13),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 字幕
|
||||||
|
BottomControlType.subtitle: Obx(
|
||||||
|
() => _.vttSubtitles.isEmpty
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
child: PopupMenuButton<Map<String, String>>(
|
||||||
|
onSelected: (Map<String, String> value) {
|
||||||
|
_.setSubtitle(value);
|
||||||
|
},
|
||||||
|
initialValue: _.vttSubtitles[_.vttSubtitlesIndex.value],
|
||||||
|
color: Colors.black.withOpacity(0.8),
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
return _.vttSubtitles.map((Map<String, String> subtitle) {
|
||||||
|
return PopupMenuItem<Map<String, String>>(
|
||||||
|
value: subtitle,
|
||||||
|
child: Text(
|
||||||
|
"${subtitle['title']}",
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: const Icon(
|
||||||
|
Icons.closed_caption_off_outlined,
|
||||||
|
size: 22,
|
||||||
|
color: Colors.white,
|
||||||
|
semanticLabel: '字幕',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 播放速度
|
||||||
|
BottomControlType.speed: SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
child: PopupMenuButton<double>(
|
||||||
|
onSelected: (double value) {
|
||||||
|
_.setPlaybackSpeed(value);
|
||||||
|
},
|
||||||
|
initialValue: _.playbackSpeed,
|
||||||
|
color: Colors.black.withOpacity(0.8),
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
return _.speedsList.map((double speed) {
|
||||||
|
return PopupMenuItem<double>(
|
||||||
|
height: 35,
|
||||||
|
padding: const EdgeInsets.only(left: 30),
|
||||||
|
value: speed,
|
||||||
|
child: Text(
|
||||||
|
"${speed}X",
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 13),
|
||||||
|
semanticsLabel: "$speed倍速",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Obx(() => Text("${_.playbackSpeed}X",
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 13),
|
||||||
|
semanticsLabel: "${_.playbackSpeed}倍速")),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
/// 全屏
|
||||||
|
BottomControlType.fullscreen: SizedBox(
|
||||||
|
width: 42,
|
||||||
|
height: 30,
|
||||||
|
child: Obx(() => ComBtn(
|
||||||
|
tooltip: _.isFullScreen.value ? '退出全屏' : '全屏',
|
||||||
|
icon: Icon(
|
||||||
|
_.isFullScreen.value ? Icons.fullscreen_exit : Icons.fullscreen,
|
||||||
|
size: 24,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: () => _.triggerFullScreen!(status: !_.isFullScreen.value),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
final List<Widget> list = [];
|
||||||
|
var userSpecifyItem = widget.bottomList ??
|
||||||
|
[
|
||||||
|
BottomControlType.playOrPause,
|
||||||
|
BottomControlType.time,
|
||||||
|
// BottomControlType.pre,
|
||||||
|
// BottomControlType.next,
|
||||||
|
BottomControlType.space,
|
||||||
|
BottomControlType.episode,
|
||||||
|
BottomControlType.fit,
|
||||||
|
BottomControlType.subtitle,
|
||||||
|
BottomControlType.speed,
|
||||||
|
BottomControlType.fullscreen,
|
||||||
|
];
|
||||||
|
for (var i = 0; i < userSpecifyItem.length; i++) {
|
||||||
|
list.add(videoProgressWidgets[userSpecifyItem[i]]!);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final PlPlayerController _ = widget.controller;
|
final PlPlayerController _ = widget.controller;
|
||||||
@@ -318,7 +594,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
() => Align(
|
() => Align(
|
||||||
child: AnimatedOpacity(
|
child: AnimatedOpacity(
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
opacity: _ctr.volumeIndicator.value ? 1.0 : 0.0,
|
opacity: _volumeIndicator.value ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -337,9 +613,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
width: 28.0,
|
width: 28.0,
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
_ctr.volumeValue.value == 0.0
|
_volumeValue.value == 0.0
|
||||||
? Icons.volume_off
|
? Icons.volume_off
|
||||||
: _ctr.volumeValue.value < 0.5
|
: _volumeValue.value < 0.5
|
||||||
? Icons.volume_down
|
? Icons.volume_down
|
||||||
: Icons.volume_up,
|
: Icons.volume_up,
|
||||||
color: const Color(0xFFFFFFFF),
|
color: const Color(0xFFFFFFFF),
|
||||||
@@ -348,7 +624,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(_ctr.volumeValue.value * 100.0).round()}%',
|
'${(_volumeValue.value * 100.0).round()}%',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 13.0,
|
fontSize: 13.0,
|
||||||
@@ -369,7 +645,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
() => Align(
|
() => Align(
|
||||||
child: AnimatedOpacity(
|
child: AnimatedOpacity(
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
opacity: _ctr.brightnessIndicator.value ? 1.0 : 0.0,
|
opacity: _brightnessIndicator.value ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@@ -388,9 +664,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
width: 28.0,
|
width: 28.0,
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
_ctr.brightnessValue.value < 1.0 / 3.0
|
_brightnessValue.value < 1.0 / 3.0
|
||||||
? Icons.brightness_low
|
? Icons.brightness_low
|
||||||
: _ctr.brightnessValue.value < 2.0 / 3.0
|
: _brightnessValue.value < 2.0 / 3.0
|
||||||
? Icons.brightness_medium
|
? Icons.brightness_medium
|
||||||
: Icons.brightness_high,
|
: Icons.brightness_high,
|
||||||
color: const Color(0xFFFFFFFF),
|
color: const Color(0xFFFFFFFF),
|
||||||
@@ -400,7 +676,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
const SizedBox(width: 2.0),
|
const SizedBox(width: 2.0),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(_ctr.brightnessValue.value * 100.0).round()}%',
|
'${(_brightnessValue.value * 100.0).round()}%',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 13.0,
|
fontSize: 13.0,
|
||||||
@@ -528,7 +804,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
// 左边区域 👈
|
// 左边区域 👈
|
||||||
final double level = renderBox.size.height * 3;
|
final double level = renderBox.size.height * 3;
|
||||||
final double brightness =
|
final double brightness =
|
||||||
_ctr.brightnessValue.value - delta / level;
|
_brightnessValue.value - delta / level;
|
||||||
final double result = brightness.clamp(0.0, 1.0);
|
final double result = brightness.clamp(0.0, 1.0);
|
||||||
setBrightness(result);
|
setBrightness(result);
|
||||||
} else if (tapPosition < sectionWidth * 2) {
|
} else if (tapPosition < sectionWidth * 2) {
|
||||||
@@ -540,28 +816,28 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
await widget.controller.triggerFullScreen(status: status);
|
await widget.controller.triggerFullScreen(status: status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dy > _distance && dy > threshold) {
|
if (dy > _distance.value && dy > threshold) {
|
||||||
// 下滑退出全屏/进入全屏
|
// 下滑退出全屏/进入全屏
|
||||||
if (_.isFullScreen.value ^ fullScreenGestureReverse) {
|
if (_.isFullScreen.value ^ fullScreenGestureReverse) {
|
||||||
fullScreenTrigger(fullScreenGestureReverse);
|
fullScreenTrigger(fullScreenGestureReverse);
|
||||||
}
|
}
|
||||||
_distance = 0.0;
|
_distance.value = 0.0;
|
||||||
} else if (dy < _distance && dy < -threshold) {
|
} else if (dy < _distance.value && dy < -threshold) {
|
||||||
// 上划进入全屏/退出全屏
|
// 上划进入全屏/退出全屏
|
||||||
if (!_.isFullScreen.value ^ fullScreenGestureReverse) {
|
if (!_.isFullScreen.value ^ fullScreenGestureReverse) {
|
||||||
fullScreenTrigger(!fullScreenGestureReverse);
|
fullScreenTrigger(!fullScreenGestureReverse);
|
||||||
}
|
}
|
||||||
_distance = 0.0;
|
_distance.value = 0.0;
|
||||||
}
|
}
|
||||||
_distance = dy;
|
_distance.value = dy;
|
||||||
} else {
|
} else {
|
||||||
// 右边区域 👈
|
// 右边区域 👈
|
||||||
final double level = renderBox.size.height * 0.5;
|
final double level = renderBox.size.height * 0.5;
|
||||||
if (lastVolume < 0) {
|
if (lastVolume < 0) {
|
||||||
lastVolume = _ctr.volumeValue.value;
|
lastVolume = _volumeValue.value;
|
||||||
}
|
}
|
||||||
final double volume =
|
final double volume =
|
||||||
(lastVolume + _ctr.volumeValue.value - delta / level) / 2;
|
(lastVolume + _volumeValue.value - delta / level) / 2;
|
||||||
final double result = volume.clamp(0.0, 1.0);
|
final double result = volume.clamp(0.0, 1.0);
|
||||||
lastVolume = result;
|
lastVolume = result;
|
||||||
setVolume(result);
|
setVolume(result);
|
||||||
@@ -596,9 +872,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
position: 'bottom',
|
position: 'bottom',
|
||||||
child: widget.bottomControl ??
|
child: widget.bottomControl ??
|
||||||
BottomControl(
|
BottomControl(
|
||||||
controller: widget.controller,
|
controller: widget.controller,
|
||||||
triggerFullScreen:
|
buildBottomControl: buildBottomControl(),
|
||||||
widget.controller.triggerFullScreen),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -618,23 +894,23 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
}
|
}
|
||||||
if (defaultBtmProgressBehavior ==
|
if (defaultBtmProgressBehavior ==
|
||||||
BtmProgresBehavior.alwaysHide.code) {
|
BtmProgresBehavior.alwaysHide.code) {
|
||||||
return Container();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
if (defaultBtmProgressBehavior ==
|
if (defaultBtmProgressBehavior ==
|
||||||
BtmProgresBehavior.onlyShowFullScreen.code &&
|
BtmProgresBehavior.onlyShowFullScreen.code &&
|
||||||
!_.isFullScreen.value) {
|
!_.isFullScreen.value) {
|
||||||
return Container();
|
return const SizedBox();
|
||||||
} else if (defaultBtmProgressBehavior ==
|
} else if (defaultBtmProgressBehavior ==
|
||||||
BtmProgresBehavior.onlyHideFullScreen.code &&
|
BtmProgresBehavior.onlyHideFullScreen.code &&
|
||||||
_.isFullScreen.value) {
|
_.isFullScreen.value) {
|
||||||
return Container();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_.videoType.value == 'live') {
|
if (_.videoType.value == 'live') {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
if (value > max || max <= 0) {
|
if (value > max || max <= 0) {
|
||||||
return Container();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
return Positioned(
|
return Positioned(
|
||||||
bottom: -1,
|
bottom: -1,
|
||||||
@@ -752,18 +1028,17 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
/// 点击 快进/快退
|
/// 点击 快进/快退
|
||||||
Obx(
|
Obx(
|
||||||
() => Visibility(
|
() => Visibility(
|
||||||
visible: _ctr.mountSeekBackwardButton.value ||
|
visible:
|
||||||
_ctr.mountSeekForwardButton.value,
|
_mountSeekBackwardButton.value || _mountSeekForwardButton.value,
|
||||||
child: Positioned.fill(
|
child: Positioned.fill(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _ctr.mountSeekBackwardButton.value
|
child: _mountSeekBackwardButton.value
|
||||||
? TweenAnimationBuilder<double>(
|
? TweenAnimationBuilder<double>(
|
||||||
tween: Tween<double>(
|
tween: Tween<double>(
|
||||||
begin: 0.0,
|
begin: 0.0,
|
||||||
end:
|
end: _hideSeekBackwardButton.value ? 0.0 : 1.0,
|
||||||
_ctr.hideSeekBackwardButton.value ? 0.0 : 1.0,
|
|
||||||
),
|
),
|
||||||
duration: const Duration(milliseconds: 500),
|
duration: const Duration(milliseconds: 500),
|
||||||
builder: (BuildContext context, double value,
|
builder: (BuildContext context, double value,
|
||||||
@@ -773,18 +1048,16 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
onEnd: () {
|
onEnd: () {
|
||||||
if (_ctr.hideSeekBackwardButton.value) {
|
if (_hideSeekBackwardButton.value) {
|
||||||
_ctr.hideSeekBackwardButton.value = false;
|
_hideSeekBackwardButton.value = false;
|
||||||
_ctr.mountSeekBackwardButton.value = false;
|
_mountSeekBackwardButton.value = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: BackwardSeekIndicator(
|
child: BackwardSeekIndicator(
|
||||||
onChanged: (Duration value) {
|
onChanged: (Duration value) => {},
|
||||||
// _seekBarDeltaValueNotifier.value = -value;
|
|
||||||
},
|
|
||||||
onSubmitted: (Duration value) {
|
onSubmitted: (Duration value) {
|
||||||
_ctr.hideSeekBackwardButton.value = true;
|
_hideSeekBackwardButton.value = true;
|
||||||
_ctr.mountSeekBackwardButton.value = false;
|
_mountSeekBackwardButton.value = false;
|
||||||
final Player player =
|
final Player player =
|
||||||
widget.controller.videoPlayerController!;
|
widget.controller.videoPlayerController!;
|
||||||
Duration result = player.state.position - value;
|
Duration result = player.state.position - value;
|
||||||
@@ -797,7 +1070,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: nil,
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// Expanded(
|
// Expanded(
|
||||||
@@ -806,11 +1079,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _ctr.mountSeekForwardButton.value
|
child: _mountSeekForwardButton.value
|
||||||
? TweenAnimationBuilder<double>(
|
? TweenAnimationBuilder<double>(
|
||||||
tween: Tween<double>(
|
tween: Tween<double>(
|
||||||
begin: 0.0,
|
begin: 0.0,
|
||||||
end: _ctr.hideSeekForwardButton.value ? 0.0 : 1.0,
|
end: _hideSeekForwardButton.value ? 0.0 : 1.0,
|
||||||
),
|
),
|
||||||
duration: const Duration(milliseconds: 500),
|
duration: const Duration(milliseconds: 500),
|
||||||
builder: (BuildContext context, double value,
|
builder: (BuildContext context, double value,
|
||||||
@@ -820,18 +1093,16 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
onEnd: () {
|
onEnd: () {
|
||||||
if (_ctr.hideSeekForwardButton.value) {
|
if (_hideSeekForwardButton.value) {
|
||||||
_ctr.hideSeekForwardButton.value = false;
|
_hideSeekForwardButton.value = false;
|
||||||
_ctr.mountSeekForwardButton.value = false;
|
_mountSeekForwardButton.value = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: ForwardSeekIndicator(
|
child: ForwardSeekIndicator(
|
||||||
onChanged: (Duration value) {
|
onChanged: (Duration value) => {},
|
||||||
// _seekBarDeltaValueNotifier.value = value;
|
|
||||||
},
|
|
||||||
onSubmitted: (Duration value) {
|
onSubmitted: (Duration value) {
|
||||||
_ctr.hideSeekForwardButton.value = true;
|
_hideSeekForwardButton.value = true;
|
||||||
_ctr.mountSeekForwardButton.value = false;
|
_mountSeekForwardButton.value = false;
|
||||||
final Player player =
|
final Player player =
|
||||||
widget.controller.videoPlayerController!;
|
widget.controller.videoPlayerController!;
|
||||||
Duration result = player.state.position + value;
|
Duration result = player.state.position + value;
|
||||||
@@ -844,7 +1115,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: nil,
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -855,31 +1126,3 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PLVideoPlayerController extends GetxController {
|
|
||||||
RxBool mountSeekBackwardButton = false.obs;
|
|
||||||
RxBool mountSeekForwardButton = false.obs;
|
|
||||||
RxBool hideSeekBackwardButton = false.obs;
|
|
||||||
RxBool hideSeekForwardButton = false.obs;
|
|
||||||
|
|
||||||
RxDouble brightnessValue = 0.0.obs;
|
|
||||||
RxBool brightnessIndicator = false.obs;
|
|
||||||
|
|
||||||
RxDouble volumeValue = 0.0.obs;
|
|
||||||
RxBool volumeIndicator = false.obs;
|
|
||||||
|
|
||||||
RxDouble distance = 0.0.obs;
|
|
||||||
// 初始手指落下位置
|
|
||||||
RxDouble initTapPositoin = 0.0.obs;
|
|
||||||
|
|
||||||
RxBool volumeInterceptEventStream = false.obs;
|
|
||||||
|
|
||||||
// 双击快进 展示样式
|
|
||||||
void onDoubleTapSeekForward() {
|
|
||||||
mountSeekForwardButton.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void onDoubleTapSeekBackward() {
|
|
||||||
mountSeekBackwardButton.value = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ import '../../../utils/utils.dart';
|
|||||||
|
|
||||||
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||||
final PlPlayerController? controller;
|
final PlPlayerController? controller;
|
||||||
final Function? triggerFullScreen;
|
final List<Widget>? buildBottomControl;
|
||||||
const BottomControl({this.controller, this.triggerFullScreen, Key? key})
|
const BottomControl({
|
||||||
: super(key: key);
|
this.controller,
|
||||||
|
this.buildBottomControl,
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
||||||
@@ -95,147 +98,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [...buildBottomControl!],
|
||||||
controller != null
|
|
||||||
? PlayOrPauseButton(
|
|
||||||
controller: _,
|
|
||||||
)
|
|
||||||
: nil,
|
|
||||||
// 播放时间
|
|
||||||
Obx(() {
|
|
||||||
return Text(
|
|
||||||
Utils.timeFormat(_.positionSeconds.value),
|
|
||||||
style: textStyle,
|
|
||||||
semanticsLabel:
|
|
||||||
'已播放${Utils.durationReadFormat(Utils.timeFormat(_.positionSeconds.value))}',
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
const ExcludeSemantics(
|
|
||||||
child: Text(
|
|
||||||
'/',
|
|
||||||
style: textStyle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 2),
|
|
||||||
Obx(
|
|
||||||
() => Text(
|
|
||||||
Utils.timeFormat(_.durationSeconds.value),
|
|
||||||
style: textStyle,
|
|
||||||
semanticsLabel:
|
|
||||||
'共${Utils.durationReadFormat(Utils.timeFormat(_.durationSeconds.value))}',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 30,
|
|
||||||
child: TextButton(
|
|
||||||
onPressed: () => _.toggleVideoFit(),
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
|
||||||
),
|
|
||||||
child: Obx(
|
|
||||||
() => Text(
|
|
||||||
_.videoFitDEsc.value,
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 13),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => _.vttSubtitles.isEmpty
|
|
||||||
? const SizedBox(
|
|
||||||
width: 0,
|
|
||||||
)
|
|
||||||
: SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 30,
|
|
||||||
child: PopupMenuButton<Map<String, String>>(
|
|
||||||
onSelected: (Map<String, String> value) {
|
|
||||||
controller!.setSubtitle(value);
|
|
||||||
},
|
|
||||||
initialValue:
|
|
||||||
_.vttSubtitles[_.vttSubtitlesIndex.value],
|
|
||||||
color: Colors.black.withOpacity(0.8),
|
|
||||||
itemBuilder: (BuildContext context) {
|
|
||||||
return _.vttSubtitles
|
|
||||||
.map((Map<String, String> subtitle) {
|
|
||||||
return PopupMenuItem<Map<String, String>>(
|
|
||||||
value: subtitle,
|
|
||||||
child: Text(
|
|
||||||
"${subtitle['title']}",
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 42,
|
|
||||||
height: 30,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: const Icon(
|
|
||||||
Icons.closed_caption_off_outlined,
|
|
||||||
size: 22,
|
|
||||||
color: Colors.white,
|
|
||||||
semanticLabel: '字幕',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 30,
|
|
||||||
child: PopupMenuButton<double>(
|
|
||||||
onSelected: (double value) {
|
|
||||||
controller!.setPlaybackSpeed(value);
|
|
||||||
},
|
|
||||||
initialValue: _.playbackSpeed,
|
|
||||||
color: Colors.black.withOpacity(0.8),
|
|
||||||
itemBuilder: (BuildContext context) {
|
|
||||||
return _.speedsList.map((double speed) {
|
|
||||||
return PopupMenuItem<double>(
|
|
||||||
height: 35,
|
|
||||||
padding: const EdgeInsets.only(left: 30),
|
|
||||||
value: speed,
|
|
||||||
child: Text(
|
|
||||||
"${speed}X",
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 13),
|
|
||||||
semanticsLabel: "$speed倍速",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 42,
|
|
||||||
height: 30,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Obx(() => Text("${_.playbackSpeed}X",
|
|
||||||
style:
|
|
||||||
const TextStyle(color: Colors.white, fontSize: 13),
|
|
||||||
semanticsLabel: "${_.playbackSpeed}倍速")),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// 全屏
|
|
||||||
SizedBox(
|
|
||||||
width: 42,
|
|
||||||
height: 30,
|
|
||||||
child: Obx(() => ComBtn(
|
|
||||||
tooltip: _.isFullScreen.value ? '退出全屏' : '全屏',
|
|
||||||
icon: Icon(
|
|
||||||
_.isFullScreen.value
|
|
||||||
? Icons.fullscreen_exit
|
|
||||||
: Icons.fullscreen,
|
|
||||||
size: 24,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
fuc: () =>
|
|
||||||
triggerFullScreen!(status: !_.isFullScreen.value),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Utils {
|
|||||||
|
|
||||||
static String numFormat(dynamic number) {
|
static String numFormat(dynamic number) {
|
||||||
if (number == null) {
|
if (number == null) {
|
||||||
return '0';
|
return '00:00';
|
||||||
}
|
}
|
||||||
if (number is String) {
|
if (number is String) {
|
||||||
return number;
|
return number;
|
||||||
@@ -126,27 +126,20 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String timeFormat(dynamic time) {
|
static String timeFormat(dynamic time) {
|
||||||
// 1小时内
|
|
||||||
if (time is String && time.contains(':')) {
|
if (time is String && time.contains(':')) {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
if (time < 3600) {
|
if (time == null || time == 0) {
|
||||||
if (time == 0) {
|
return '00:00';
|
||||||
return time.toString();
|
|
||||||
}
|
|
||||||
final int minute = time ~/ 60;
|
|
||||||
final double res = time / 60;
|
|
||||||
if (minute != res) {
|
|
||||||
return '${minute < 10 ? '0$minute' : minute}:${(time - minute * 60) < 10 ? '0${(time - minute * 60)}' : (time - minute * 60)}';
|
|
||||||
} else {
|
|
||||||
return '$minute:00';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
final int hour = time ~/ 3600;
|
|
||||||
final String hourStr = hour < 10 ? '0$hour' : hour.toString();
|
|
||||||
var a = timeFormat(time - hour * 3600);
|
|
||||||
return '$hourStr:$a';
|
|
||||||
}
|
}
|
||||||
|
int hour = time ~/ 3600;
|
||||||
|
int minute = (time % 3600) ~/ 60;
|
||||||
|
int second = time % 60;
|
||||||
|
String paddingStr(int number) {
|
||||||
|
return number.toString().padLeft(2, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
return '${hour > 0 ? "${paddingStr(hour)}:" : ""}${paddingStr(minute)}:${paddingStr(second)}';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 完全相对时间显示
|
// 完全相对时间显示
|
||||||
|
|||||||
Reference in New Issue
Block a user