Compare commits

...

23 Commits

Author SHA1 Message Date
33d28f51d1 feat: 未登录状态切换直播画质提示 2024-03-17 00:36:00 +08:00
a37f3b8b5b Merge branch 'main' into feature-liveRoomRender 2024-03-16 23:35:18 +08:00
a57f5e8b2f Merge branch 'main' of github.com:guozhigq/pilipala 2024-03-16 23:12:52 +08:00
beb640ac83 Merge branch 'fix-bangumi' 2024-03-16 23:12:31 +08:00
1b54f07bc3 merge main 2024-03-16 23:11:47 +08:00
fca0588377 Merge pull request #628 from guozhigq/feature-customBottomControl
Feature custom bottom control
2024-03-16 23:08:22 +08:00
4865948609 Merge branch 'fix-whisperRenderError' 2024-03-16 23:07:01 +08:00
09eb180fc7 Merge branch 'main' of github.com:guozhigq/pilipala 2024-03-16 23:06:18 +08:00
3fab47780b Merge pull request #635 from guozhigq/feature-videoDetailCodeCleanUp
feat: 视频番剧详情页代码整理
2024-03-16 23:05:58 +08:00
453cbd7b1c Merge branch 'main' of github.com:guozhigq/pilipala 2024-03-16 23:03:09 +08:00
0bf2326c73 Merge branch 'feature-updateVideoDetailStructure' 2024-03-16 23:02:43 +08:00
2985c624ab mod: stream close 2024-03-16 23:02:21 +08:00
32cbc2759e Merge branch 'main' into feature-updateVideoDetailStructure 2024-03-16 22:52:15 +08:00
13c77957fe fix: 番剧badge 2024-03-16 22:48:47 +08:00
f382c8f377 Merge pull request #632 from kalac2232/main
feature: 动态页跳转登录
2024-03-16 21:56:18 +08:00
491bc87251 fix: 私信列表渲染异常 issues #295 2024-03-15 23:26:43 +08:00
5e8d9b524b Merge branch 'fix-favoritesCalc' 2024-03-14 23:31:00 +08:00
357133fa97 fix:去除无用的setState 2024-03-14 10:00:32 +08:00
da2bbeedff mod: 默认直播画质设置 2024-03-13 23:12:34 +08:00
bc9ea43cd2 feat: 视频番剧详情页代码整理 2024-03-12 23:45:22 +08:00
882957e2f8 feature:动态页的错误按钮在未登录状态下的按钮为直接跳转登录页 2024-03-12 14:34:32 +08:00
98aaca286b feat: 直播画质切换 2024-03-11 00:02:11 +08:00
6fdfcb888d feat: 播放器底部控制栏自定义 2024-03-10 19:41:23 +08:00
18 changed files with 879 additions and 953 deletions

View File

@ -31,14 +31,14 @@ class MsgHttp {
} catch (err) { } catch (err) {
return { return {
'status': false, 'status': false,
'date': [], 'data': [],
'msg': err.toString(), 'msg': err.toString(),
}; };
} }
} else { } else {
return { return {
'status': false, 'status': false,
'date': [], 'data': [],
'msg': res.data['message'], 'msg': res.data['message'],
}; };
} }

View File

@ -0,0 +1,43 @@
enum LiveQuality {
dolby,
super4K,
origin,
bluRay,
superHD,
smooth,
flunt,
}
extension LiveQualityCode on LiveQuality {
static final List<int> _codeList = [
30000,
20000,
10000,
400,
250,
150,
80,
];
int get code => _codeList[index];
static LiveQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return LiveQuality.values[index];
}
return null;
}
}
extension VideoQualityDesc on LiveQuality {
static final List<String> _descList = [
'杜比',
'4K',
'原画',
'蓝光',
'超清',
'高清',
'流畅',
];
get description => _descList[index];
}

View File

@ -25,13 +25,6 @@ class BangumiIntroController extends GetxController {
? int.tryParse(Get.parameters['epId']!) ? int.tryParse(Get.parameters['epId']!)
: null; : null;
// 是否预渲染 骨架屏
bool preRender = false;
// 视频详情 上个页面传入
Map? videoItem = {};
BangumiInfoModel? bangumiItem;
// 请求状态 // 请求状态
RxBool isLoading = false.obs; RxBool isLoading = false.obs;
@ -63,27 +56,6 @@ class BangumiIntroController extends GetxController {
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
if (Get.arguments.isNotEmpty as bool) {
if (Get.arguments.containsKey('bangumiItem') as bool) {
preRender = true;
bangumiItem = Get.arguments['bangumiItem'];
// bangumiItem!['pic'] = args.pic;
// if (args.title is String) {
// videoItem!['title'] = args.title;
// } else {
// String str = '';
// for (Map map in args.title) {
// str += map['text'];
// }
// videoItem!['title'] = str;
// }
// if (args.stat != null) {
// videoItem!['stat'] = args.stat;
// }
// videoItem!['pubdate'] = args.pubdate;
// videoItem!['owner'] = args.owner;
}
}
userInfo = userInfoCache.get('userInfoCache'); userInfo = userInfoCache.get('userInfoCache');
userLogin = userInfo != null; userLogin = userInfo != null;
} }
@ -183,20 +155,21 @@ class BangumiIntroController extends GetxController {
actions: [ actions: [
TextButton(onPressed: () => Get.back(), child: const Text('取消')), TextButton(onPressed: () => Get.back(), child: const Text('取消')),
TextButton( TextButton(
onPressed: () async { onPressed: () async {
var res = await VideoHttp.coinVideo( var res = await VideoHttp.coinVideo(
bvid: bvid, multiply: _tempThemeValue); bvid: bvid, multiply: _tempThemeValue);
if (res['status']) { if (res['status']) {
SmartDialog.showToast('投币成功 👏'); SmartDialog.showToast('投币成功 👏');
hasCoin.value = true; hasCoin.value = true;
bangumiDetail.value.stat!['coins'] = bangumiDetail.value.stat!['coins'] =
bangumiDetail.value.stat!['coins'] + _tempThemeValue; bangumiDetail.value.stat!['coins'] + _tempThemeValue;
} else { } else {
SmartDialog.showToast(res['msg']); SmartDialog.showToast(res['msg']);
} }
Get.back(); Get.back();
}, },
child: const Text('确定')) child: const Text('确定'),
)
], ],
); );
}); });

View File

@ -12,11 +12,10 @@ import 'package:pilipala/models/bangumi/info.dart';
import 'package:pilipala/pages/bangumi/widgets/bangumi_panel.dart'; import 'package:pilipala/pages/bangumi/widgets/bangumi_panel.dart';
import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/introduction/widgets/action_item.dart'; import 'package:pilipala/pages/video/detail/introduction/widgets/action_item.dart';
import 'package:pilipala/pages/video/detail/introduction/widgets/action_row_item.dart';
import 'package:pilipala/pages/video/detail/introduction/widgets/fav_panel.dart'; import 'package:pilipala/pages/video/detail/introduction/widgets/fav_panel.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import '../../../common/widgets/http_error.dart';
import 'controller.dart'; import 'controller.dart';
import 'widgets/intro_detail.dart'; import 'widgets/intro_detail.dart';
@ -51,9 +50,6 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
cid = widget.cid!; cid = widget.cid!;
bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag); bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag);
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag); videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
bangumiIntroController.bangumiDetail.listen((BangumiInfoModel value) {
bangumiDetail = value;
});
_futureBuilderFuture = bangumiIntroController.queryBangumiIntro(); _futureBuilderFuture = bangumiIntroController.queryBangumiIntro();
videoDetailCtr.cid.listen((int p0) { videoDetailCtr.cid.listen((int p0) {
cid = p0; cid = p0;
@ -68,27 +64,32 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
future: _futureBuilderFuture, future: _futureBuilderFuture,
builder: (BuildContext context, AsyncSnapshot snapshot) { builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
return const SliverToBoxAdapter(child: SizedBox());
}
if (snapshot.data['status']) { if (snapshot.data['status']) {
// 请求成功 // 请求成功
return Obx(
return BangumiInfo( () => BangumiInfo(
loadingStatus: false, bangumiDetail: bangumiIntroController.bangumiDetail.value,
bangumiDetail: bangumiDetail, cid: cid,
cid: cid, ),
); );
} else { } else {
// 请求错误 // 请求错误
// return HttpError( return HttpError(
// errMsg: snapshot.data['msg'], errMsg: snapshot.data['msg'],
// fn: () => Get.back(), fn: () => Get.back(),
// ); );
return const SizedBox();
} }
} else { } else {
return BangumiInfo( return const SliverToBoxAdapter(
loadingStatus: true, child: SizedBox(
bangumiDetail: bangumiDetail, height: 100,
cid: cid, child: Center(
child: CircularProgressIndicator(),
),
),
); );
} }
}, },
@ -99,12 +100,10 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
class BangumiInfo extends StatefulWidget { class BangumiInfo extends StatefulWidget {
const BangumiInfo({ const BangumiInfo({
super.key, super.key,
this.loadingStatus = false,
this.bangumiDetail, this.bangumiDetail,
this.cid, this.cid,
}); });
final bool loadingStatus;
final BangumiInfoModel? bangumiDetail; final BangumiInfoModel? bangumiDetail;
final int? cid; final int? cid;
@ -117,7 +116,6 @@ class _BangumiInfoState extends State<BangumiInfo> {
late final BangumiIntroController bangumiIntroController; late final BangumiIntroController bangumiIntroController;
late final VideoDetailController videoDetailCtr; late final VideoDetailController videoDetailCtr;
Box localCache = GStrorage.localCache; Box localCache = GStrorage.localCache;
late final BangumiInfoModel? bangumiItem;
late double sheetHeight; late double sheetHeight;
int? cid; int? cid;
bool isProcessing = false; bool isProcessing = false;
@ -136,13 +134,10 @@ class _BangumiInfoState extends State<BangumiInfo> {
super.initState(); super.initState();
bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag); bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag);
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag); videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
bangumiItem = bangumiIntroController.bangumiItem;
sheetHeight = localCache.get('sheetHeight'); sheetHeight = localCache.get('sheetHeight');
cid = widget.cid!; cid = widget.cid!;
print('cid: $cid');
videoDetailCtr.cid.listen((p0) { videoDetailCtr.cid.listen((p0) {
cid = p0; cid = p0;
print('cid: $cid');
setState(() {}); setState(() {});
}); });
} }
@ -182,207 +177,155 @@ class _BangumiInfoState extends State<BangumiInfo> {
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
left: StyleString.safeSpace, right: StyleString.safeSpace, top: 20), left: StyleString.safeSpace, right: StyleString.safeSpace, top: 20),
sliver: SliverToBoxAdapter( sliver: SliverToBoxAdapter(
child: !widget.loadingStatus || bangumiItem != null child: Column(
? Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [ children: [
Row( NetworkImgLayer(
crossAxisAlignment: CrossAxisAlignment.start, width: 105,
children: [ height: 160,
Stack( src: widget.bangumiDetail!.cover!,
children: [ ),
NetworkImgLayer( PBadge(
width: 105, text: '评分 ${widget.bangumiDetail!.rating!['score']!}',
height: 160, top: null,
src: !widget.loadingStatus right: 6,
? widget.bangumiDetail!.cover! bottom: 6,
: bangumiItem!.cover!, left: null,
), ),
if (bangumiItem != null && ],
bangumiItem!.rating != null) ),
PBadge( const SizedBox(width: 10),
text: Expanded(
'评分 ${!widget.loadingStatus ? widget.bangumiDetail!.rating!['score']! : bangumiItem!.rating!['score']!}', child: InkWell(
top: null, onTap: () => showIntroDetail(),
right: 6, child: SizedBox(
bottom: 6, height: 158,
left: null, child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Expanded(
child: Text(
widget.bangumiDetail!.title!,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
), ),
], const SizedBox(width: 20),
), SizedBox(
const SizedBox(width: 10), width: 34,
Expanded( height: 34,
child: InkWell( child: IconButton(
onTap: () => showIntroDetail(), style: ButtonStyle(
child: SizedBox( padding: MaterialStateProperty.all(
height: 158, EdgeInsets.zero),
child: Column( backgroundColor:
crossAxisAlignment: CrossAxisAlignment.start, MaterialStateProperty.resolveWith(
mainAxisSize: MainAxisSize.min, (Set<MaterialState> states) {
children: [ return t.colorScheme.primaryContainer
Row( .withOpacity(0.7);
children: [ }),
Expanded(
child: Text(
!widget.loadingStatus
? widget.bangumiDetail!.title!
: bangumiItem!.title!,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 20),
SizedBox(
width: 34,
height: 34,
child: IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
EdgeInsets.zero),
backgroundColor:
MaterialStateProperty.resolveWith(
(Set<MaterialState> states) {
return t
.colorScheme.primaryContainer
.withOpacity(0.7);
}),
),
onPressed: () =>
bangumiIntroController.bangumiAdd(),
icon: Icon(
Icons.favorite_border_rounded,
color: t.colorScheme.primary,
size: 22,
),
),
),
],
), ),
Row( onPressed: () =>
children: [ bangumiIntroController.bangumiAdd(),
StatView( icon: Icon(
theme: 'gray', Icons.favorite_border_rounded,
view: !widget.loadingStatus color: t.colorScheme.primary,
? widget.bangumiDetail!.stat!['views'] size: 22,
: bangumiItem!.stat!['views'],
size: 'medium',
),
const SizedBox(width: 6),
StatDanMu(
theme: 'gray',
danmu: !widget.loadingStatus
? widget
.bangumiDetail!.stat!['danmakus']
: bangumiItem!.stat!['danmakus'],
size: 'medium',
),
],
), ),
const SizedBox(height: 6), ),
Row(
children: [
Text(
!widget.loadingStatus
? (widget.bangumiDetail!.areas!
.isNotEmpty
? widget.bangumiDetail!.areas!
.first['name']
: '')
: (bangumiItem!.areas!.isNotEmpty
? bangumiItem!
.areas!.first['name']
: ''),
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
const SizedBox(width: 6),
Text(
!widget.loadingStatus
? widget.bangumiDetail!
.publish!['pub_time_show']
: bangumiItem!
.publish!['pub_time_show'],
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
],
),
// const SizedBox(height: 4),
Text(
!widget.loadingStatus
? widget.bangumiDetail!.newEp!['desc']
: bangumiItem!.newEp!['desc'],
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
// const SizedBox(height: 10),
const Spacer(),
Text(
'简介:${!widget.loadingStatus ? widget.bangumiDetail!.evaluate! : bangumiItem!.evaluate!}',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: t.colorScheme.outline,
),
),
],
), ),
],
),
Row(
children: [
StatView(
theme: 'gray',
view: widget.bangumiDetail!.stat!['views'],
size: 'medium',
),
const SizedBox(width: 6),
StatDanMu(
theme: 'gray',
danmu: widget.bangumiDetail!.stat!['danmakus'],
size: 'medium',
),
],
),
const SizedBox(height: 6),
Row(
children: [
Text(
(widget.bangumiDetail!.areas!.isNotEmpty
? widget.bangumiDetail!.areas!.first['name']
: ''),
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
const SizedBox(width: 6),
Text(
widget.bangumiDetail!.publish!['pub_time_show'],
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
],
),
Text(
widget.bangumiDetail!.newEp!['desc'],
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
), ),
), ),
), const Spacer(),
], Text(
'简介:${widget.bangumiDetail!.evaluate!}',
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: t.colorScheme.outline,
),
),
],
),
), ),
const SizedBox(height: 6),
// 点赞收藏转发 布局样式1
// SingleChildScrollView(
// padding: const EdgeInsets.only(top: 7, bottom: 7),
// scrollDirection: Axis.horizontal,
// child: actionRow(
// context,
// bangumiIntroController,
// videoDetailCtr,
// ),
// ),
// 点赞收藏转发 布局样式2
actionGrid(context, bangumiIntroController),
// 番剧分p
if ((!widget.loadingStatus &&
widget.bangumiDetail!.episodes!.isNotEmpty) ||
bangumiItem != null &&
bangumiItem!.episodes!.isNotEmpty) ...[
BangumiPanel(
pages: bangumiItem != null
? bangumiItem!.episodes!
: widget.bangumiDetail!.episodes!,
cid: cid ??
(bangumiItem != null
? bangumiItem!.episodes!.first.cid
: widget.bangumiDetail!.episodes!.first.cid),
sheetHeight: sheetHeight,
changeFuc: (bvid, cid, aid) => bangumiIntroController
.changeSeasonOrbangu(bvid, cid, aid),
)
],
],
)
: const SizedBox(
height: 100,
child: Center(
child: CircularProgressIndicator(),
), ),
), ),
), ],
),
const SizedBox(height: 6),
/// 点赞收藏转发
actionGrid(context, bangumiIntroController),
// 番剧分p
if (widget.bangumiDetail!.episodes!.isNotEmpty) ...[
BangumiPanel(
pages: widget.bangumiDetail!.episodes!,
cid: cid ?? widget.bangumiDetail!.episodes!.first.cid,
sheetHeight: sheetHeight,
changeFuc: (bvid, cid, aid) =>
bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid),
bangumiDetail: bangumiIntroController.bangumiDetail.value,
)
],
],
)),
); );
} }
@ -402,57 +345,44 @@ class _BangumiInfoState extends State<BangumiInfo> {
children: <Widget>[ children: <Widget>[
Obx( Obx(
() => ActionItem( () => ActionItem(
icon: const Icon(FontAwesomeIcons.thumbsUp), icon: const Icon(FontAwesomeIcons.thumbsUp),
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp), selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
onTap: onTap: handleState(bangumiIntroController.actionLikeVideo),
handleState(bangumiIntroController.actionLikeVideo), selectStatus: bangumiIntroController.hasLike.value,
selectStatus: bangumiIntroController.hasLike.value, text: widget.bangumiDetail!.stat!['likes']!.toString(),
loadingStatus: false, ),
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['likes']!.toString()
: bangumiItem!.stat!['likes']!.toString()),
), ),
Obx( Obx(
() => ActionItem( () => ActionItem(
icon: const Icon(FontAwesomeIcons.b), icon: const Icon(FontAwesomeIcons.b),
selectIcon: const Icon(FontAwesomeIcons.b), selectIcon: const Icon(FontAwesomeIcons.b),
onTap: onTap: handleState(bangumiIntroController.actionCoinVideo),
handleState(bangumiIntroController.actionCoinVideo), selectStatus: bangumiIntroController.hasCoin.value,
selectStatus: bangumiIntroController.hasCoin.value, text: widget.bangumiDetail!.stat!['coins']!.toString(),
loadingStatus: false, ),
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['coins']!.toString()
: bangumiItem!.stat!['coins']!.toString()),
), ),
Obx( Obx(
() => ActionItem( () => ActionItem(
icon: const Icon(FontAwesomeIcons.star), icon: const Icon(FontAwesomeIcons.star),
selectIcon: const Icon(FontAwesomeIcons.solidStar), selectIcon: const Icon(FontAwesomeIcons.solidStar),
onTap: () => showFavBottomSheet(), onTap: () => showFavBottomSheet(),
selectStatus: bangumiIntroController.hasFav.value, selectStatus: bangumiIntroController.hasFav.value,
loadingStatus: false, text: widget.bangumiDetail!.stat!['favorite']!.toString(),
text: !widget.loadingStatus ),
? widget.bangumiDetail!.stat!['favorite']!.toString()
: bangumiItem!.stat!['favorite']!.toString()),
), ),
ActionItem( ActionItem(
icon: const Icon(FontAwesomeIcons.comment), icon: const Icon(FontAwesomeIcons.comment),
selectIcon: const Icon(FontAwesomeIcons.reply), selectIcon: const Icon(FontAwesomeIcons.reply),
onTap: () => videoDetailCtr.tabCtr.animateTo(1), onTap: () => videoDetailCtr.tabCtr.animateTo(1),
selectStatus: false, selectStatus: false,
loadingStatus: false, text: widget.bangumiDetail!.stat!['reply']!.toString(),
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['reply']!.toString()
: bangumiItem!.stat!['reply']!.toString(),
), ),
ActionItem( ActionItem(
icon: const Icon(FontAwesomeIcons.shareFromSquare), icon: const Icon(FontAwesomeIcons.shareFromSquare),
onTap: () => bangumiIntroController.actionShareVideo(), onTap: () => bangumiIntroController.actionShareVideo(),
selectStatus: false, selectStatus: false,
loadingStatus: false, text: widget.bangumiDetail!.stat!['share']!.toString(),
text: !widget.loadingStatus ),
? widget.bangumiDetail!.stat!['share']!.toString()
: bangumiItem!.stat!['share']!.toString()),
], ],
), ),
), ),
@ -460,63 +390,4 @@ class _BangumiInfoState extends State<BangumiInfo> {
); );
}); });
} }
Widget actionRow(BuildContext context, videoIntroController, videoDetailCtr) {
return Row(children: [
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.thumbsUp),
onTap: handleState(videoIntroController.actionLikeVideo),
selectStatus: videoIntroController.hasLike.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['likes']!.toString()
: '-',
),
),
const SizedBox(width: 8),
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.b),
onTap: handleState(videoIntroController.actionCoinVideo),
selectStatus: videoIntroController.hasCoin.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['coins']!.toString()
: '-',
),
),
const SizedBox(width: 8),
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.heart),
onTap: () => showFavBottomSheet(),
selectStatus: videoIntroController.hasFav.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['favorite']!.toString()
: '-',
),
),
const SizedBox(width: 8),
ActionRowItem(
icon: const Icon(FontAwesomeIcons.comment),
onTap: () {
videoDetailCtr.tabCtr.animateTo(1);
},
selectStatus: false,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
? widget.bangumiDetail!.stat!['reply']!.toString()
: '-',
),
const SizedBox(width: 8),
ActionRowItem(
icon: const Icon(FontAwesomeIcons.share),
onTap: () => videoIntroController.actionShareVideo(),
selectStatus: false,
loadingStatus: widget.loadingStatus,
text: '转发'),
]);
}
} }

View File

@ -14,12 +14,14 @@ class BangumiPanel extends StatefulWidget {
this.cid, this.cid,
this.sheetHeight, this.sheetHeight,
this.changeFuc, this.changeFuc,
this.bangumiDetail,
}); });
final List<EpisodeItem> pages; final List<EpisodeItem> pages;
final int? cid; final int? cid;
final double? sheetHeight; final double? sheetHeight;
final Function? changeFuc; final Function? changeFuc;
final BangumiInfoModel? bangumiDetail;
@override @override
State<BangumiPanel> createState() => _BangumiPanelState(); State<BangumiPanel> createState() => _BangumiPanelState();
@ -87,7 +89,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
) )
: null, : null,
title: Text( title: Text(
'${index + 1}${page.longTitle!}', '${page.title}${page.longTitle!}',
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: isCurrentIndex color: isCurrentIndex
@ -96,9 +98,11 @@ class _BangumiPanelState extends State<BangumiPanel> {
), ),
), ),
trailing: page.badge != null trailing: page.badge != null
? Image.asset( ? Text(
'assets/images/big-vip.png', page.badge!,
height: 20, style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
) )
: const SizedBox(), : const SizedBox(),
); );
@ -201,11 +205,11 @@ class _BangumiPanelState extends State<BangumiPanel> {
return Column( return Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(top: 10, bottom: 6), padding: const EdgeInsets.only(top: 10, bottom: 10),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
const Text(''), const Text(''),
Expanded( Expanded(
child: Text( child: Text(
' 正在播放:${widget.pages[currentIndex].longTitle}', ' 正在播放:${widget.pages[currentIndex].longTitle}',
@ -225,7 +229,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
), ),
onPressed: () => showBangumiPanel(), onPressed: () => showBangumiPanel(),
child: Text( child: Text(
'${widget.pages.length}', '${widget.bangumiDetail!.newEp!['desc']}',
style: const TextStyle(fontSize: 13), style: const TextStyle(fontSize: 13),
), ),
), ),
@ -278,23 +282,15 @@ class _BangumiPanelState extends State<BangumiPanel> {
), ),
const SizedBox(width: 2), const SizedBox(width: 2),
if (widget.pages[i].badge != null) ...[ if (widget.pages[i].badge != null) ...[
if (widget.pages[i].badge == '会员') ...[ const Spacer(),
Image.asset( Text(
'assets/images/big-vip.png', widget.pages[i].badge!,
height: 16, style: TextStyle(
fontSize: 12,
color:
Theme.of(context).colorScheme.primary,
), ),
], ),
if (widget.pages[i].badge != '会员') ...[
const Spacer(),
Text(
widget.pages[i].badge!,
style: TextStyle(
fontSize: 11,
color:
Theme.of(context).colorScheme.primary,
),
),
],
] ]
], ],
), ),

View File

@ -14,6 +14,7 @@ import 'package:pilipala/pages/main/index.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import '../mine/controller.dart';
import 'controller.dart'; import 'controller.dart';
import 'widgets/dynamic_panel.dart'; import 'widgets/dynamic_panel.dart';
import 'widgets/up_panel.dart'; import 'widgets/up_panel.dart';
@ -28,6 +29,7 @@ class DynamicsPage extends StatefulWidget {
class _DynamicsPageState extends State<DynamicsPage> class _DynamicsPageState extends State<DynamicsPage>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
final DynamicsController _dynamicsController = Get.put(DynamicsController()); final DynamicsController _dynamicsController = Get.put(DynamicsController());
final MineController mineController = Get.put(MineController());
late Future _futureBuilderFuture; late Future _futureBuilderFuture;
late Future _futureBuilderFutureUp; late Future _futureBuilderFutureUp;
Box userInfoCache = GStrorage.userInfo; Box userInfoCache = GStrorage.userInfo;
@ -256,6 +258,14 @@ class _DynamicsPageState extends State<DynamicsPage>
} }
}, },
); );
} else if (data['msg'] == "账号未登录") {
return HttpError(
errMsg: data['msg'],
btnText: "去登录",
fn: () {
mineController.onLogin();
},
);
} else { } else {
return HttpError( return HttpError(
errMsg: data['msg'], errMsg: data['msg'],

View File

@ -1,6 +1,8 @@
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/http/constants.dart'; import 'package:pilipala/http/constants.dart';
import 'package:pilipala/http/live.dart'; import 'package:pilipala/http/live.dart';
import 'package:pilipala/models/live/quality.dart';
import 'package:pilipala/models/live/room_info.dart'; import 'package:pilipala/models/live/room_info.dart';
import 'package:pilipala/plugin/pl_player/index.dart'; import 'package:pilipala/plugin/pl_player/index.dart';
import '../../models/live/room_info_h5.dart'; import '../../models/live/room_info_h5.dart';
@ -19,10 +21,16 @@ class LiveRoomController extends GetxController {
PlPlayerController.getInstance(videoType: 'live'); PlPlayerController.getInstance(videoType: 'live');
Rx<RoomInfoH5Model> roomInfoH5 = RoomInfoH5Model().obs; Rx<RoomInfoH5Model> roomInfoH5 = RoomInfoH5Model().obs;
late bool enableCDN; late bool enableCDN;
late int currentQn;
int? tempCurrentQn;
late List<Map<String, dynamic>> acceptQnList;
RxString currentQnDesc = ''.obs;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
currentQn = setting.get(SettingBoxKey.defaultLiveQa,
defaultValue: LiveQuality.values.last.code);
roomId = int.parse(Get.parameters['roomid']!); roomId = int.parse(Get.parameters['roomid']!);
if (Get.arguments != null) { if (Get.arguments != null) {
liveItem = Get.arguments['liveItem']; liveItem = Get.arguments['liveItem'];
@ -57,11 +65,28 @@ class LiveRoomController extends GetxController {
} }
Future queryLiveInfo() async { Future queryLiveInfo() async {
var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: 10000); var res = await LiveHttp.liveRoomInfo(roomId: roomId, qn: currentQn);
if (res['status']) { if (res['status']) {
List<CodecItem> codec = List<CodecItem> codec =
res['data'].playurlInfo.playurl.stream.first.format.first.codec; res['data'].playurlInfo.playurl.stream.first.format.first.codec;
CodecItem item = codec.first; CodecItem item = codec.first;
// 以服务端返回的码率为准
currentQn = item.currentQn!;
if (tempCurrentQn != null && tempCurrentQn == currentQn) {
SmartDialog.showToast('画质切换失败,请检查登录状态');
}
List acceptQn = item.acceptQn!;
acceptQnList = acceptQn.map((e) {
return {
'code': e,
'desc': LiveQuality.values
.firstWhere((element) => element.code == e)
.description,
};
}).toList();
currentQnDesc.value = LiveQuality.values
.firstWhere((element) => element.code == currentQn)
.description;
String videoUrl = enableCDN String videoUrl = enableCDN
? VideoUtils.getCdnUrl(item) ? VideoUtils.getCdnUrl(item)
: (item.urlInfo?.first.host)! + : (item.urlInfo?.first.host)! +
@ -90,4 +115,17 @@ class LiveRoomController extends GetxController {
} }
return res; return res;
} }
// 修改画质
void changeQn(int qn) async {
tempCurrentQn = currentQn;
if (currentQn == qn) {
return;
}
currentQn = qn;
currentQnDesc.value = LiveQuality.values
.firstWhere((element) => element.code == currentQn)
.description;
await queryLiveInfo();
}
} }

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:floating/floating.dart'; import 'package:floating/floating.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/models/video/play/url.dart'; import 'package:pilipala/models/video/play/url.dart';
import 'package:pilipala/pages/live_room/index.dart'; import 'package:pilipala/pages/live_room/index.dart';
@ -83,6 +84,30 @@ class _BottomControlState extends State<BottomControl> {
// ), // ),
// ), // ),
// const SizedBox(width: 4), // const SizedBox(width: 4),
SizedBox(
width: 30,
child: PopupMenuButton<int>(
padding: EdgeInsets.zero,
onSelected: (value) {
widget.liveRoomCtr!.changeQn(value);
},
child: Obx(
() => Text(
widget.liveRoomCtr!.currentQnDesc.value,
style: const TextStyle(color: Colors.white, fontSize: 13),
),
),
itemBuilder: (BuildContext context) {
return widget.liveRoomCtr!.acceptQnList.map((e) {
return PopupMenuItem<int>(
value: e['code'],
child: Text(e['desc']),
);
}).toList();
},
),
),
const SizedBox(width: 10),
if (Platform.isAndroid) ...[ if (Platform.isAndroid) ...[
SizedBox( SizedBox(
width: 34, width: 34,
@ -110,7 +135,7 @@ class _BottomControlState extends State<BottomControl> {
), ),
), ),
), ),
const SizedBox(width: 4), const SizedBox(width: 10),
], ],
ComBtn( ComBtn(
icon: const Icon( icon: const Icon(

View File

@ -10,6 +10,7 @@ import 'package:pilipala/services/service_locator.dart';
import 'package:pilipala/utils/global_data.dart'; import 'package:pilipala/utils/global_data.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import '../../models/live/quality.dart';
import 'widgets/switch_item.dart'; import 'widgets/switch_item.dart';
class PlaySetting extends StatefulWidget { class PlaySetting extends StatefulWidget {
@ -22,6 +23,7 @@ class PlaySetting extends StatefulWidget {
class _PlaySettingState extends State<PlaySetting> { class _PlaySettingState extends State<PlaySetting> {
Box setting = GStrorage.setting; Box setting = GStrorage.setting;
late dynamic defaultVideoQa; late dynamic defaultVideoQa;
late dynamic defaultLiveQa;
late dynamic defaultAudioQa; late dynamic defaultAudioQa;
late dynamic defaultDecode; late dynamic defaultDecode;
late int defaultFullScreenMode; late int defaultFullScreenMode;
@ -32,6 +34,8 @@ class _PlaySettingState extends State<PlaySetting> {
super.initState(); super.initState();
defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa, defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa,
defaultValue: VideoQuality.values.last.code); defaultValue: VideoQuality.values.last.code);
defaultLiveQa = setting.get(SettingBoxKey.defaultLiveQa,
defaultValue: LiveQuality.values.last.code);
defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa, defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
defaultValue: AudioQuality.values.last.code); defaultValue: AudioQuality.values.last.code);
defaultDecode = setting.get(SettingBoxKey.defaultDecode, defaultDecode = setting.get(SettingBoxKey.defaultDecode,
@ -157,9 +161,9 @@ class _PlaySettingState extends State<PlaySetting> {
}), }),
ListTile( ListTile(
dense: false, dense: false,
title: Text('默认画质', style: titleStyle), title: Text('默认视频画质', style: titleStyle),
subtitle: Text( subtitle: Text(
'当前画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}', '当前默认画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
style: subTitleStyle, style: subTitleStyle,
), ),
onTap: () async { onTap: () async {
@ -167,7 +171,7 @@ class _PlaySettingState extends State<PlaySetting> {
context: context, context: context,
builder: (context) { builder: (context) {
return SelectDialog<int>( return SelectDialog<int>(
title: '默认画质', title: '默认视频画质',
value: defaultVideoQa, value: defaultVideoQa,
values: VideoQuality.values.reversed.map((e) { values: VideoQuality.values.reversed.map((e) {
return {'title': e.description, 'value': e.code}; return {'title': e.description, 'value': e.code};
@ -181,6 +185,32 @@ class _PlaySettingState extends State<PlaySetting> {
} }
}, },
), ),
ListTile(
dense: false,
title: Text('默认直播画质', style: titleStyle),
subtitle: Text(
'当前默认画质${LiveQualityCode.fromCode(defaultLiveQa)!.description!}',
style: subTitleStyle,
),
onTap: () async {
int? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<int>(
title: '默认直播画质',
value: defaultLiveQa,
values: LiveQuality.values.reversed.map((e) {
return {'title': e.description, 'value': e.code};
}).toList());
},
);
if (result != null) {
defaultLiveQa = result;
setting.put(SettingBoxKey.defaultLiveQa, result);
setState(() {});
}
},
),
ListTile( ListTile(
dense: false, dense: false,
title: Text('默认音质', style: titleStyle), title: Text('默认音质', style: titleStyle),

View File

@ -25,13 +25,6 @@ class VideoIntroController extends GetxController {
VideoIntroController({required this.bvid}); VideoIntroController({required this.bvid});
// 视频bvid // 视频bvid
String bvid; String bvid;
// 是否预渲染 骨架屏
bool preRender = false;
// 视频详情 上个页面传入
Map? videoItem = {};
// 请求状态 // 请求状态
RxBool isLoading = false.obs; RxBool isLoading = false.obs;
@ -74,26 +67,6 @@ class VideoIntroController extends GetxController {
try { try {
heroTag = Get.arguments['heroTag']; heroTag = Get.arguments['heroTag'];
} catch (_) {} } catch (_) {}
if (Get.arguments.isNotEmpty) {
if (Get.arguments.containsKey('videoItem')) {
preRender = true;
var args = Get.arguments['videoItem'];
var keys = Get.arguments.keys.toList();
videoItem!['pic'] = args.pic;
if (args.title is String) {
videoItem!['title'] = args.title;
} else {
String str = '';
for (Map map in args.title) {
str += map['text'];
}
videoItem!['title'] = str;
}
videoItem!['stat'] = keys.contains('stat') && args.stat;
videoItem!['pubdate'] = keys.contains('pubdate') && args.pubdate;
videoItem!['owner'] = keys.contains('owner') && args.owner;
}
}
userLogin = userInfo != null; userLogin = userInfo != null;
lastPlayCid.value = int.parse(Get.parameters['cid']!); lastPlayCid.value = int.parse(Get.parameters['cid']!);
isShowOnlineTotal = isShowOnlineTotal =

View File

@ -15,9 +15,7 @@ import 'package:pilipala/pages/video/detail/widgets/ai_detail.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart'; import 'package:pilipala/utils/utils.dart';
import 'widgets/action_item.dart'; import 'widgets/action_item.dart';
import 'widgets/action_row_item.dart';
import 'widgets/fav_panel.dart'; import 'widgets/fav_panel.dart';
import 'widgets/intro_detail.dart'; import 'widgets/intro_detail.dart';
import 'widgets/page.dart'; import 'widgets/page.dart';
@ -78,7 +76,6 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
// 请求成功 // 请求成功
return Obx( return Obx(
() => VideoInfo( () => VideoInfo(
loadingStatus: false,
videoDetail: videoIntroController.videoDetail.value, videoDetail: videoIntroController.videoDetail.value,
heroTag: heroTag, heroTag: heroTag,
bvid: widget.bvid, bvid: widget.bvid,
@ -96,11 +93,13 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
); );
} }
} else { } else {
return VideoInfo( return const SliverToBoxAdapter(
loadingStatus: true, child: SizedBox(
videoDetail: videoDetail, height: 100,
heroTag: heroTag, child: Center(
bvid: widget.bvid, child: CircularProgressIndicator(),
),
),
); );
} }
}, },
@ -109,14 +108,12 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
} }
class VideoInfo extends StatefulWidget { class VideoInfo extends StatefulWidget {
final bool loadingStatus;
final VideoDetailData? videoDetail; final VideoDetailData? videoDetail;
final String? heroTag; final String? heroTag;
final String bvid; final String bvid;
const VideoInfo({ const VideoInfo({
Key? key, Key? key,
this.loadingStatus = false,
this.videoDetail, this.videoDetail,
this.heroTag, this.heroTag,
required this.bvid, required this.bvid,
@ -127,18 +124,12 @@ class VideoInfo extends StatefulWidget {
} }
class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin { class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
// final String heroTag = Get.arguments['heroTag'];
late String heroTag; late String heroTag;
late final VideoIntroController videoIntroController; late final VideoIntroController videoIntroController;
late final VideoDetailController videoDetailCtr; late final VideoDetailController videoDetailCtr;
late final Map<dynamic, dynamic> videoItem;
final Box<dynamic> localCache = GStrorage.localCache; final Box<dynamic> localCache = GStrorage.localCache;
final Box<dynamic> setting = GStrorage.setting; final Box<dynamic> setting = GStrorage.setting;
late double sheetHeight; late double sheetHeight;
late final bool loadingStatus; // 加载状态
late final dynamic owner; late final dynamic owner;
late final dynamic follower; late final dynamic follower;
late final dynamic followStatus; late final dynamic followStatus;
@ -163,14 +154,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
videoIntroController = videoIntroController =
Get.put(VideoIntroController(bvid: widget.bvid), tag: heroTag); Get.put(VideoIntroController(bvid: widget.bvid), tag: heroTag);
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag); videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
videoItem = videoIntroController.videoItem!;
sheetHeight = localCache.get('sheetHeight'); sheetHeight = localCache.get('sheetHeight');
loadingStatus = widget.loadingStatus; owner = widget.videoDetail!.owner;
owner = loadingStatus ? videoItem['owner'] : widget.videoDetail!.owner; follower = Utils.numFormat(videoIntroController.userStat['follower']);
follower = loadingStatus
? '-'
: Utils.numFormat(videoIntroController.userStat['follower']);
followStatus = videoIntroController.followStatus; followStatus = videoIntroController.followStatus;
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true); enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
} }
@ -224,9 +211,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
// 视频介绍 // 视频介绍
showIntroDetail() { showIntroDetail() {
if (loadingStatus) {
return;
}
feedBack(); feedBack();
showBottomSheet( showBottomSheet(
context: context, context: context,
@ -240,13 +224,9 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
// 用户主页 // 用户主页
onPushMember() { onPushMember() {
feedBack(); feedBack();
mid = !loadingStatus mid = widget.videoDetail!.owner!.mid!;
? widget.videoDetail!.owner!.mid
: videoItem['owner'].mid;
memberHeroTag = Utils.makeHeroTag(mid); memberHeroTag = Utils.makeHeroTag(mid);
String face = !loadingStatus String face = widget.videoDetail!.owner!.face!;
? widget.videoDetail!.owner!.face
: videoItem['owner'].face;
Get.toNamed('/member?mid=$mid', Get.toNamed('/member?mid=$mid',
arguments: {'face': face, 'heroTag': memberHeroTag}); arguments: {'face': face, 'heroTag': memberHeroTag});
} }
@ -273,221 +253,181 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
top: 16, top: 16,
), ),
sliver: SliverToBoxAdapter( sliver: SliverToBoxAdapter(
child: !loadingStatus child: Column(
? Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ GestureDetector(
GestureDetector( behavior: HitTestBehavior.translucent,
behavior: HitTestBehavior.translucent, onTap: () => showIntroDetail(),
onTap: () => showIntroDetail(), child: Text(
child: Text( widget.videoDetail!.title!,
!loadingStatus style: const TextStyle(
? widget.videoDetail!.title fontSize: 18,
: videoItem['title'], fontWeight: FontWeight.bold,
style: const TextStyle( ),
fontSize: 18, maxLines: 2,
fontWeight: FontWeight.bold, overflow: TextOverflow.ellipsis,
), ),
maxLines: 2, ),
overflow: TextOverflow.ellipsis, Stack(
), children: [
), GestureDetector(
Stack( behavior: HitTestBehavior.translucent,
onTap: () => showIntroDetail(),
child: Padding(
padding: const EdgeInsets.only(top: 7, bottom: 6),
child: Row(
children: [ children: [
GestureDetector( StatView(
behavior: HitTestBehavior.translucent, theme: 'gray',
onTap: () => showIntroDetail(), view: widget.videoDetail!.stat!.view,
child: Padding( size: 'medium',
padding: const EdgeInsets.only(top: 7, bottom: 6), ),
child: Row( const SizedBox(width: 10),
children: [ StatDanMu(
StatView( theme: 'gray',
theme: 'gray', danmu: widget.videoDetail!.stat!.danmaku,
view: !loadingStatus size: 'medium',
? widget.videoDetail!.stat!.view ),
: videoItem['stat'].view, const SizedBox(width: 10),
size: 'medium', Text(
), Utils.dateFormat(widget.videoDetail!.pubdate,
const SizedBox(width: 10), formatType: 'detail'),
StatDanMu( style: TextStyle(
theme: 'gray', fontSize: 12,
danmu: !loadingStatus color: t.colorScheme.outline,
? widget.videoDetail!.stat!.danmaku
: videoItem['stat'].danmaku,
size: 'medium',
),
const SizedBox(width: 10),
Text(
Utils.dateFormat(
!loadingStatus
? widget.videoDetail!.pubdate
: videoItem['pubdate'],
formatType: 'detail'),
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
const SizedBox(width: 10),
if (videoIntroController.isShowOnlineTotal)
Obx(
() => Text(
'${videoIntroController.total.value}人在看',
style: TextStyle(
fontSize: 12,
color: t.colorScheme.outline,
),
),
),
],
),
), ),
), ),
if (enableAi) const SizedBox(width: 10),
Positioned( if (videoIntroController.isShowOnlineTotal)
right: 10, Obx(
top: 6, () => Text(
child: GestureDetector( '${videoIntroController.total.value}人在看',
onTap: () async {
final res =
await videoIntroController.aiConclusion();
if (res['status']) {
showAiBottomSheet();
}
},
child:
Image.asset('assets/images/ai.png', height: 22),
),
)
],
),
// 点赞收藏转发 布局样式1
// SingleChildScrollView(
// padding: const EdgeInsets.only(top: 7, bottom: 7),
// scrollDirection: Axis.horizontal,
// child: actionRow(
// context,
// videoIntroController,
// videoDetailCtr,
// ),
// ),
// 点赞收藏转发 布局样式2
actionGrid(context, videoIntroController),
// 合集
if (!loadingStatus &&
widget.videoDetail!.ugcSeason != null) ...[
Obx(
() => SeasonPanel(
ugcSeason: widget.videoDetail!.ugcSeason!,
cid: videoIntroController.lastPlayCid.value != 0
? videoIntroController.lastPlayCid.value
: widget.videoDetail!.pages!.first.cid,
sheetHeight: sheetHeight,
changeFuc: (bvid, cid, aid) => videoIntroController
.changeSeasonOrbangu(bvid, cid, aid),
),
)
],
if (!loadingStatus &&
widget.videoDetail!.pages != null &&
widget.videoDetail!.pages!.length > 1) ...[
Obx(() => PagesPanel(
pages: widget.videoDetail!.pages!,
cid: videoIntroController.lastPlayCid.value,
sheetHeight: sheetHeight,
changeFuc: (cid) =>
videoIntroController.changeSeasonOrbangu(
videoIntroController.bvid, cid, null),
))
],
GestureDetector(
onTap: onPushMember,
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 12, horizontal: 4),
child: Row(
children: [
NetworkImgLayer(
type: 'avatar',
src: loadingStatus
? owner.face
: widget.videoDetail!.owner!.face,
width: 34,
height: 34,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
const SizedBox(width: 10),
Text(owner.name,
style: const TextStyle(fontSize: 13)),
const SizedBox(width: 6),
Text(
follower,
style: TextStyle( style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize, fontSize: 12,
color: outline, color: t.colorScheme.outline,
), ),
), ),
const Spacer(), ),
Obx(() => AnimatedOpacity( ],
opacity: loadingStatus ||
videoIntroController
.followStatus.isEmpty
? 0
: 1,
duration: const Duration(milliseconds: 50),
child: SizedBox(
height: 32,
child: Obx(
() => videoIntroController
.followStatus.isNotEmpty
? TextButton(
onPressed: videoIntroController
.actionRelationMod,
style: TextButton.styleFrom(
padding: const EdgeInsets.only(
left: 8, right: 8),
foregroundColor:
followStatus['attribute'] != 0
? outline
: t.colorScheme.onPrimary,
backgroundColor:
followStatus['attribute'] != 0
? t.colorScheme
.onInverseSurface
: t.colorScheme
.primary, // 设置按钮背景色
),
child: Text(
followStatus['attribute'] != 0
? '已关注'
: '关注',
style: TextStyle(
fontSize: t.textTheme
.labelMedium!.fontSize),
),
)
: ElevatedButton(
onPressed: videoIntroController
.actionRelationMod,
child: const Text('关注'),
),
),
),
)),
],
),
),
), ),
],
)
: const SizedBox(
height: 100,
child: Center(
child: CircularProgressIndicator(),
), ),
), ),
), if (enableAi)
Positioned(
right: 10,
top: 6,
child: GestureDetector(
onTap: () async {
final res = await videoIntroController.aiConclusion();
if (res['status']) {
showAiBottomSheet();
}
},
child: Image.asset('assets/images/ai.png', height: 22),
),
)
],
),
/// 点赞收藏转发
actionGrid(context, videoIntroController),
// 合集
if (widget.videoDetail!.ugcSeason != null) ...[
Obx(
() => SeasonPanel(
ugcSeason: widget.videoDetail!.ugcSeason!,
cid: videoIntroController.lastPlayCid.value != 0
? videoIntroController.lastPlayCid.value
: widget.videoDetail!.pages!.first.cid,
sheetHeight: sheetHeight,
changeFuc: (bvid, cid, aid) =>
videoIntroController.changeSeasonOrbangu(bvid, cid, aid),
),
)
],
if (widget.videoDetail!.pages != null &&
widget.videoDetail!.pages!.length > 1) ...[
Obx(() => PagesPanel(
pages: widget.videoDetail!.pages!,
cid: videoIntroController.lastPlayCid.value,
sheetHeight: sheetHeight,
changeFuc: (cid) => videoIntroController.changeSeasonOrbangu(
videoIntroController.bvid, cid, null),
))
],
GestureDetector(
onTap: onPushMember,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 4),
child: Row(
children: [
NetworkImgLayer(
type: 'avatar',
src: widget.videoDetail!.owner!.face,
width: 34,
height: 34,
fadeInDuration: Duration.zero,
fadeOutDuration: Duration.zero,
),
const SizedBox(width: 10),
Text(owner.name, style: const TextStyle(fontSize: 13)),
const SizedBox(width: 6),
Text(
follower,
style: TextStyle(
fontSize: t.textTheme.labelSmall!.fontSize,
color: outline,
),
),
const Spacer(),
Obx(() => AnimatedOpacity(
opacity:
videoIntroController.followStatus.isEmpty ? 0 : 1,
duration: const Duration(milliseconds: 50),
child: SizedBox(
height: 32,
child: Obx(
() => videoIntroController.followStatus.isNotEmpty
? TextButton(
onPressed:
videoIntroController.actionRelationMod,
style: TextButton.styleFrom(
padding: const EdgeInsets.only(
left: 8, right: 8),
foregroundColor:
followStatus['attribute'] != 0
? outline
: t.colorScheme.onPrimary,
backgroundColor:
followStatus['attribute'] != 0
? t.colorScheme.onInverseSurface
: t.colorScheme
.primary, // 设置按钮背景色
),
child: Text(
followStatus['attribute'] != 0
? '已关注'
: '关注',
style: TextStyle(
fontSize: t
.textTheme.labelMedium!.fontSize),
),
)
: ElevatedButton(
onPressed:
videoIntroController.actionRelationMod,
child: const Text('关注'),
),
),
),
)),
],
),
),
),
],
)),
); );
} }
@ -509,10 +449,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp), selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
onTap: handleState(videoIntroController.actionLikeVideo), onTap: handleState(videoIntroController.actionLikeVideo),
selectStatus: videoIntroController.hasLike.value, selectStatus: videoIntroController.hasLike.value,
loadingStatus: loadingStatus, text: widget.videoDetail!.stat!.like!.toString()),
text: !loadingStatus
? widget.videoDetail!.stat!.like!.toString()
: '-'),
), ),
// ActionItem( // ActionItem(
// icon: const Icon(FontAwesomeIcons.clock), // icon: const Icon(FontAwesomeIcons.clock),
@ -522,104 +459,38 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
// text: '稍后再看'), // text: '稍后再看'),
Obx( Obx(
() => ActionItem( () => ActionItem(
icon: const Icon(FontAwesomeIcons.b), icon: const Icon(FontAwesomeIcons.b),
selectIcon: const Icon(FontAwesomeIcons.b), selectIcon: const Icon(FontAwesomeIcons.b),
onTap: handleState(videoIntroController.actionCoinVideo), onTap: handleState(videoIntroController.actionCoinVideo),
selectStatus: videoIntroController.hasCoin.value, selectStatus: videoIntroController.hasCoin.value,
loadingStatus: loadingStatus, text: widget.videoDetail!.stat!.coin!.toString(),
text: !loadingStatus ),
? widget.videoDetail!.stat!.coin!.toString()
: '-'),
), ),
Obx( Obx(
() => ActionItem( () => ActionItem(
icon: const Icon(FontAwesomeIcons.star), icon: const Icon(FontAwesomeIcons.star),
selectIcon: const Icon(FontAwesomeIcons.solidStar), selectIcon: const Icon(FontAwesomeIcons.solidStar),
onTap: () => showFavBottomSheet(), onTap: () => showFavBottomSheet(),
onLongPress: () => showFavBottomSheet(type: 'longPress'), onLongPress: () => showFavBottomSheet(type: 'longPress'),
selectStatus: videoIntroController.hasFav.value, selectStatus: videoIntroController.hasFav.value,
loadingStatus: loadingStatus, text: widget.videoDetail!.stat!.favorite!.toString(),
text: !loadingStatus ),
? widget.videoDetail!.stat!.favorite!.toString()
: '-'),
), ),
ActionItem( ActionItem(
icon: const Icon(FontAwesomeIcons.comment), icon: const Icon(FontAwesomeIcons.comment),
onTap: () => videoDetailCtr.tabCtr.animateTo(1), onTap: () => videoDetailCtr.tabCtr.animateTo(1),
selectStatus: false, selectStatus: false,
loadingStatus: loadingStatus, text: widget.videoDetail!.stat!.reply!.toString(),
text: !loadingStatus ),
? widget.videoDetail!.stat!.reply!.toString()
: '评论'),
ActionItem( ActionItem(
icon: const Icon(FontAwesomeIcons.shareFromSquare), icon: const Icon(FontAwesomeIcons.shareFromSquare),
onTap: () => videoIntroController.actionShareVideo(), onTap: () => videoIntroController.actionShareVideo(),
selectStatus: false, selectStatus: false,
loadingStatus: loadingStatus, text: '分享',
text: '分享'), ),
], ],
), ),
); );
}); });
} }
Widget actionRow(BuildContext context, videoIntroController, videoDetailCtr) {
return Row(children: <Widget>[
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.thumbsUp),
onTap: handleState(videoIntroController.actionLikeVideo),
selectStatus: videoIntroController.hasLike.value,
loadingStatus: loadingStatus,
text:
!loadingStatus ? widget.videoDetail!.stat!.like!.toString() : '-',
),
),
const SizedBox(width: 8),
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.b),
onTap: handleState(videoIntroController.actionCoinVideo),
selectStatus: videoIntroController.hasCoin.value,
loadingStatus: loadingStatus,
text:
!loadingStatus ? widget.videoDetail!.stat!.coin!.toString() : '-',
),
),
const SizedBox(width: 8),
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.heart),
onTap: () => showFavBottomSheet(),
onLongPress: () => showFavBottomSheet(type: 'longPress'),
selectStatus: videoIntroController.hasFav.value,
loadingStatus: loadingStatus,
text: !loadingStatus
? widget.videoDetail!.stat!.favorite!.toString()
: '-',
),
),
const SizedBox(width: 8),
ActionRowItem(
icon: const Icon(FontAwesomeIcons.comment),
onTap: () {
videoDetailCtr.tabCtr.animateTo(1);
},
selectStatus: false,
loadingStatus: loadingStatus,
text:
!loadingStatus ? widget.videoDetail!.stat!.reply!.toString() : '-',
),
const SizedBox(width: 8),
ActionRowItem(
icon: const Icon(FontAwesomeIcons.share),
onTap: () => videoIntroController.actionShareVideo(),
selectStatus: false,
loadingStatus: loadingStatus,
// text: !loadingStatus
// ? widget.videoDetail!.stat!.share!.toString()
// : '-',
text: '转发'),
]);
}
} }

View File

@ -7,7 +7,6 @@ class ActionItem extends StatelessWidget {
final Icon? selectIcon; final Icon? selectIcon;
final Function? onTap; final Function? onTap;
final Function? onLongPress; final Function? onLongPress;
final bool? loadingStatus;
final String? text; final String? text;
final bool selectStatus; final bool selectStatus;
@ -17,7 +16,6 @@ class ActionItem extends StatelessWidget {
this.selectIcon, this.selectIcon,
this.onTap, this.onTap,
this.onLongPress, this.onLongPress,
this.loadingStatus,
this.text, this.text,
this.selectStatus = false, this.selectStatus = false,
}) : super(key: key); }) : super(key: key);
@ -43,25 +41,15 @@ class ActionItem extends StatelessWidget {
: Icon(icon!.icon!, : Icon(icon!.icon!,
size: 18, color: Theme.of(context).colorScheme.outline), size: 18, color: Theme.of(context).colorScheme.outline),
const SizedBox(height: 6), const SizedBox(height: 6),
AnimatedOpacity( Text(
opacity: loadingStatus! ? 0 : 1, text ?? '',
duration: const Duration(milliseconds: 200), style: TextStyle(
child: AnimatedSwitcher( color: selectStatus
duration: const Duration(milliseconds: 300), ? Theme.of(context).colorScheme.primary
transitionBuilder: (Widget child, Animation<double> animation) { : Theme.of(context).colorScheme.outline,
return ScaleTransition(scale: animation, child: child); fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
},
child: Text(
text ?? '',
key: ValueKey<String>(text ?? ''),
style: TextStyle(
color: selectStatus
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize),
),
), ),
), )
], ],
), ),
); );

View File

@ -194,6 +194,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
floating.toggleAutoPip(autoEnter: false); floating.toggleAutoPip(autoEnter: false);
floating.dispose(); floating.dispose();
} }
appbarStream.close();
super.dispose(); super.dispose();
} }

View File

@ -180,7 +180,8 @@ class _WhisperPageState extends State<WhisperPage> {
sessionList[i] sessionList[i]
.lastMsg .lastMsg
.content[ .content[
'reply_content']) 'reply_content'] ??
'不支持的消息类型')
: '不支持的消息类型', : '不支持的消息类型',
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View File

@ -0,0 +1,10 @@
enum BottomControlType {
pre,
playOrPause,
next,
time,
space,
fit,
speed,
fullscreen,
}

View File

@ -8,7 +8,6 @@ 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:pilipala/models/common/gesture_mode.dart'; import 'package:pilipala/models/common/gesture_mode.dart';
import 'package:pilipala/plugin/pl_player/controller.dart'; import 'package:pilipala/plugin/pl_player/controller.dart';
import 'package:pilipala/plugin/pl_player/models/duration.dart'; import 'package:pilipala/plugin/pl_player/models/duration.dart';
@ -19,12 +18,14 @@ import 'package:pilipala/utils/storage.dart';
import 'package:screen_brightness/screen_brightness.dart'; import 'package:screen_brightness/screen_brightness.dart';
import '../../utils/global_data.dart'; import '../../utils/global_data.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({
@ -32,6 +33,7 @@ class PLVideoPlayer extends StatefulWidget {
this.headerControl, this.headerControl,
this.bottomControl, this.bottomControl,
this.danmuWidget, this.danmuWidget,
this.bottomList,
super.key, super.key,
}); });
@ -39,6 +41,7 @@ class PLVideoPlayer extends StatefulWidget {
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,26 +51,22 @@ 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());
// 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;
@ -82,11 +81,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
DateTime? lastFullScreenToggleTime; DateTime? lastFullScreenToggleTime;
void onDoubleTapSeekBackward() { void onDoubleTapSeekBackward() {
_ctr.onDoubleTapSeekBackward(); _mountSeekBackwardButton.value = true;
} }
void onDoubleTapSeekForward() { void onDoubleTapSeekForward() {
_ctr.onDoubleTapSeekForward(); _mountSeekForwardButton.value = true;
} }
// 双击播放、暂停 // 双击播放、暂停
@ -138,10 +137,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 +148,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 +163,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 +179,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 +196,134 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
super.dispose(); super.dispose();
} }
// 动态构建底部控制条
List<Widget> buildBottomControl() {
const TextStyle textStyle = TextStyle(
color: Colors.white,
fontSize: 12,
);
final PlPlayerController _ = widget.controller;
Map<BottomControlType, Widget> videoProgressWidgets = {
/// 上一集
BottomControlType.pre: ComBtn(
icon: const Icon(
Icons.skip_previous_outlined,
size: 15,
color: Colors.white,
),
fuc: () {},
),
/// 播放暂停
BottomControlType.playOrPause: PlayOrPauseButton(
controller: _,
),
/// 下一集
BottomControlType.next: ComBtn(
icon: const Icon(
Icons.last_page_outlined,
size: 15,
color: Colors.white,
),
fuc: () {},
),
/// 时间进度
BottomControlType.time: Row(
children: [
Obx(() {
return Text(
_.durationSeconds.value >= 3600
? printDurationWithHours(
Duration(seconds: _.positionSeconds.value))
: printDuration(Duration(seconds: _.positionSeconds.value)),
style: textStyle,
);
}),
const SizedBox(width: 2),
const Text('/', style: textStyle),
const SizedBox(width: 2),
Obx(
() => Text(
_.durationSeconds.value >= 3600
? printDurationWithHours(
Duration(seconds: _.durationSeconds.value))
: printDuration(Duration(seconds: _.durationSeconds.value)),
style: textStyle,
),
),
],
),
/// 空白占位
BottomControlType.space: const Spacer(),
/// 画面比例
BottomControlType.fit: SizedBox(
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.speed: SizedBox(
width: 45,
height: 34,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {},
child: Obx(
() => Text(
'${_.playbackSpeed.toString()}X',
style: textStyle,
),
),
),
),
/// 字幕
/// 全屏
BottomControlType.fullscreen: ComBtn(
icon: Obx(
() => Icon(
_.isFullScreen.value
? FontAwesomeIcons.compress
: FontAwesomeIcons.expand,
size: 15,
color: Colors.white,
),
),
fuc: () => _.triggerFullScreen(),
),
};
final List<Widget> list = [];
var userSpecifyItem = widget.bottomList ??
[
BottomControlType.playOrPause,
BottomControlType.time,
BottomControlType.space,
BottomControlType.fit,
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;
@ -316,7 +443,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,
@ -335,9 +462,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),
@ -346,7 +473,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,
@ -367,7 +494,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,
@ -386,9 +513,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),
@ -398,7 +525,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,
@ -489,7 +616,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
pos.clamp(Duration.zero, _.duration.value); pos.clamp(Duration.zero, _.duration.value);
_.onUpdatedSliderProgress(result); _.onUpdatedSliderProgress(result);
_.onChangedSliderStart(); _.onChangedSliderStart();
// _initTapPositoin = tapPosition;
}, },
onHorizontalDragEnd: (DragEndDetails details) { onHorizontalDragEnd: (DragEndDetails details) {
if (_.videoType.value == 'live' || _.controlsLock.value) { if (_.videoType.value == 'live' || _.controlsLock.value) {
@ -521,7 +647,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
: screenWidth * 9 / 16) * : screenWidth * 9 / 16) *
3; 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) {
@ -530,29 +656,29 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
const double threshold = 7.0; // 滑动阈值 const double threshold = 7.0; // 滑动阈值
final bool flag = final bool flag =
fullScreenGestureMode != FullScreenGestureMode.values.last; fullScreenGestureMode != FullScreenGestureMode.values.last;
if (dy > _distance && dy > threshold) { if (dy > _distance.value && dy > threshold) {
if (_.isFullScreen.value ^ flag) { if (_.isFullScreen.value ^ flag) {
lastFullScreenToggleTime = DateTime.now(); lastFullScreenToggleTime = DateTime.now();
// 下滑退出全屏 // 下滑退出全屏
await widget.controller.triggerFullScreen(status: flag); await widget.controller.triggerFullScreen(status: flag);
} }
_distance = 0.0; _distance.value = 0.0;
} else if (dy < _distance && dy < -threshold) { } else if (dy < _distance.value && dy < -threshold) {
if (!_.isFullScreen.value ^ flag) { if (!_.isFullScreen.value ^ flag) {
lastFullScreenToggleTime = DateTime.now(); lastFullScreenToggleTime = DateTime.now();
// 上滑进入全屏 // 上滑进入全屏
await widget.controller.triggerFullScreen(status: !flag); await widget.controller.triggerFullScreen(status: !flag);
} }
_distance = 0.0; _distance.value = 0.0;
} }
_distance = dy; _distance.value = dy;
} else { } else {
// 右边区域 👈 // 右边区域 👈
final double level = (_.isFullScreen.value final double level = (_.isFullScreen.value
? Get.size.height ? Get.size.height
: screenWidth * 9 / 16) * : screenWidth * 9 / 16) *
3; 3;
final double volume = _ctr.volumeValue.value - delta / level; final double volume = _volumeValue.value - delta / level;
final double result = volume.clamp(0.0, 1.0); final double result = volume.clamp(0.0, 1.0);
setVolume(result); setVolume(result);
} }
@ -585,9 +711,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
position: 'bottom', position: 'bottom',
child: widget.bottomControl ?? child: widget.bottomControl ??
BottomControl( BottomControl(
controller: widget.controller, controller: widget.controller,
triggerFullScreen: triggerFullScreen: _.triggerFullScreen,
widget.controller.triggerFullScreen), buildBottomControl: buildBottomControl(),
),
), ),
), ),
], ],
@ -607,23 +734,23 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
} }
if (defaultBtmProgressBehavior == if (defaultBtmProgressBehavior ==
BtmProgresBehavior.alwaysHide.code) { BtmProgresBehavior.alwaysHide.code) {
return nil; return const SizedBox();
} }
if (defaultBtmProgressBehavior == if (defaultBtmProgressBehavior ==
BtmProgresBehavior.onlyShowFullScreen.code && BtmProgresBehavior.onlyShowFullScreen.code &&
!_.isFullScreen.value) { !_.isFullScreen.value) {
return nil; return const SizedBox();
} else if (defaultBtmProgressBehavior == } else if (defaultBtmProgressBehavior ==
BtmProgresBehavior.onlyHideFullScreen.code && BtmProgresBehavior.onlyHideFullScreen.code &&
_.isFullScreen.value) { _.isFullScreen.value) {
return nil; return const SizedBox();
} }
if (_.videoType.value == 'live') { if (_.videoType.value == 'live') {
return const SizedBox(); return const SizedBox();
} }
if (value > max || max <= 0) { if (value > max || max <= 0) {
return nil; return const SizedBox();
} }
return Positioned( return Positioned(
bottom: -1.5, bottom: -1.5,
@ -720,18 +847,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,
@ -741,17 +867,15 @@ 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;
final Player player = final Player player =
widget.controller.videoPlayerController!; widget.controller.videoPlayerController!;
Duration result = player.state.position - value; Duration result = player.state.position - value;
@ -764,7 +888,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}, },
), ),
) )
: nil, : const SizedBox(),
), ),
Expanded( Expanded(
child: SizedBox( child: SizedBox(
@ -772,11 +896,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,
@ -786,17 +910,15 @@ 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;
final Player player = final Player player =
widget.controller.videoPlayerController!; widget.controller.videoPlayerController!;
Duration result = player.state.position + value; Duration result = player.state.position + value;
@ -809,7 +931,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}, },
), ),
) )
: nil, : const SizedBox(),
), ),
], ],
), ),
@ -820,31 +942,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;
}
}

View File

@ -1,17 +1,20 @@
import 'package:audio_video_progress_bar/audio_video_progress_bar.dart'; import 'package:audio_video_progress_bar/audio_video_progress_bar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:nil/nil.dart'; import 'package:nil/nil.dart';
import 'package:pilipala/plugin/pl_player/index.dart'; import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/plugin/pl_player/widgets/play_pause_btn.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
class BottomControl extends StatelessWidget implements PreferredSizeWidget { class BottomControl extends StatelessWidget implements PreferredSizeWidget {
final PlPlayerController? controller; final PlPlayerController? controller;
final Function? triggerFullScreen; final Function? triggerFullScreen;
const BottomControl({this.controller, this.triggerFullScreen, Key? key}) final List<Widget>? buildBottomControl;
: super(key: key); const BottomControl({
this.controller,
this.triggerFullScreen,
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);
@ -20,11 +23,6 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Color colorTheme = Theme.of(context).colorScheme.primary; Color colorTheme = Theme.of(context).colorScheme.primary;
final _ = controller!; final _ = controller!;
const textStyle = TextStyle(
color: Colors.white,
fontSize: 12,
);
return Container( return Container(
color: Colors.transparent, color: Colors.transparent,
height: 90, height: 90,
@ -71,86 +69,89 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
}, },
), ),
Row( Row(
children: [ children: [...buildBottomControl!],
PlayOrPauseButton(
controller: _,
),
const SizedBox(width: 4),
// 播放时间
Obx(() {
return Text(
_.durationSeconds.value >= 3600
? printDurationWithHours(
Duration(seconds: _.positionSeconds.value))
: printDuration(
Duration(seconds: _.positionSeconds.value)),
style: textStyle,
);
}),
const SizedBox(width: 2),
const Text('/', style: textStyle),
const SizedBox(width: 2),
Obx(
() => Text(
_.durationSeconds.value >= 3600
? printDurationWithHours(
Duration(seconds: _.durationSeconds.value))
: printDuration(
Duration(seconds: _.durationSeconds.value)),
style: textStyle,
),
),
const Spacer(),
// 倍速
// Obx(
// () => SizedBox(
// width: 45,
// height: 34,
// child: TextButton(
// style: ButtonStyle(
// padding: MaterialStateProperty.all(EdgeInsets.zero),
// ),
// onPressed: () {
// _.togglePlaybackSpeed();
// },
// child: Text(
// '${_.playbackSpeed.toString()}X',
// style: textStyle,
// ),
// ),
// ),
// ),
SizedBox(
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),
),
),
),
),
const SizedBox(width: 10),
// 全屏
Obx(
() => ComBtn(
icon: Icon(
_.isFullScreen.value
? FontAwesomeIcons.compress
: FontAwesomeIcons.expand,
size: 15,
color: Colors.white,
),
fuc: () => triggerFullScreen!(),
),
),
],
), ),
// Row(
// children: [
// PlayOrPauseButton(
// controller: _,
// ),
// const SizedBox(width: 4),
// // 播放时间
// Obx(() {
// return Text(
// _.durationSeconds.value >= 3600
// ? printDurationWithHours(
// Duration(seconds: _.positionSeconds.value))
// : printDuration(
// Duration(seconds: _.positionSeconds.value)),
// style: textStyle,
// );
// }),
// const SizedBox(width: 2),
// const Text('/', style: textStyle),
// const SizedBox(width: 2),
// Obx(
// () => Text(
// _.durationSeconds.value >= 3600
// ? printDurationWithHours(
// Duration(seconds: _.durationSeconds.value))
// : printDuration(
// Duration(seconds: _.durationSeconds.value)),
// style: textStyle,
// ),
// ),
// const Spacer(),
// // 倍速
// // Obx(
// // () => SizedBox(
// // width: 45,
// // height: 34,
// // child: TextButton(
// // style: ButtonStyle(
// // padding: MaterialStateProperty.all(EdgeInsets.zero),
// // ),
// // onPressed: () {
// // _.togglePlaybackSpeed();
// // },
// // child: Text(
// // '${_.playbackSpeed.toString()}X',
// // style: textStyle,
// // ),
// // ),
// // ),
// // ),
// SizedBox(
// 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),
// ),
// ),
// ),
// ),
// const SizedBox(width: 10),
// // 全屏
// Obx(
// () => ComBtn(
// icon: Icon(
// _.isFullScreen.value
// ? FontAwesomeIcons.compress
// : FontAwesomeIcons.expand,
// size: 15,
// color: Colors.white,
// ),
// fuc: () => triggerFullScreen!(),
// ),
// ),
// ],
// ),
const SizedBox(height: 12), const SizedBox(height: 12),
], ],
), ),

View File

@ -84,6 +84,7 @@ class SettingBoxKey {
autoUpgradeEnable = 'autoUpgradeEnable', autoUpgradeEnable = 'autoUpgradeEnable',
feedBackEnable = 'feedBackEnable', feedBackEnable = 'feedBackEnable',
defaultVideoQa = 'defaultVideoQa', defaultVideoQa = 'defaultVideoQa',
defaultLiveQa = 'defaultLiveQa',
defaultAudioQa = 'defaultAudioQa', defaultAudioQa = 'defaultAudioQa',
autoPlayEnable = 'autoPlayEnable', autoPlayEnable = 'autoPlayEnable',
fullScreenMode = 'fullScreenMode', fullScreenMode = 'fullScreenMode',