Merge branch 'main' into fix

This commit is contained in:
guozhigq
2024-05-22 23:35:05 +08:00
15 changed files with 132 additions and 39 deletions

View File

@ -20,11 +20,13 @@ import 'network_img_layer.dart';
class VideoCardV extends StatelessWidget { class VideoCardV extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
final int crossAxisCount; final int crossAxisCount;
final Function? blockUserCb;
const VideoCardV({ const VideoCardV({
Key? key, Key? key,
required this.videoItem, required this.videoItem,
required this.crossAxisCount, required this.crossAxisCount,
this.blockUserCb,
}) : super(key: key); }) : super(key: key);
bool isStringNumeric(String str) { bool isStringNumeric(String str) {
@ -157,7 +159,11 @@ class VideoCardV extends StatelessWidget {
); );
}), }),
), ),
VideoContent(videoItem: videoItem, crossAxisCount: crossAxisCount) VideoContent(
videoItem: videoItem,
crossAxisCount: crossAxisCount,
blockUserCb: blockUserCb,
)
], ],
), ),
); );
@ -167,9 +173,14 @@ class VideoCardV extends StatelessWidget {
class VideoContent extends StatelessWidget { class VideoContent extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
final int crossAxisCount; final int crossAxisCount;
const VideoContent( final Function? blockUserCb;
{Key? key, required this.videoItem, required this.crossAxisCount})
: super(key: key); const VideoContent({
Key? key,
required this.videoItem,
required this.crossAxisCount,
this.blockUserCb,
}) : super(key: key);
Widget _buildBadge(String text, String type, [double fs = 12]) { Widget _buildBadge(String text, String type, [double fs = 12]) {
return PBadge( return PBadge(
@ -241,7 +252,10 @@ class VideoContent extends StatelessWidget {
useRootNavigator: true, useRootNavigator: true,
isScrollControlled: true, isScrollControlled: true,
builder: (context) { builder: (context) {
return MorePanel(videoItem: videoItem); return MorePanel(
videoItem: videoItem,
blockUserCb: blockUserCb,
);
}, },
); );
}, },
@ -297,11 +311,17 @@ class VideoStat extends StatelessWidget {
class MorePanel extends StatelessWidget { class MorePanel extends StatelessWidget {
final dynamic videoItem; final dynamic videoItem;
const MorePanel({super.key, required this.videoItem}); final Function? blockUserCb;
const MorePanel({
super.key,
required this.videoItem,
this.blockUserCb,
});
Future<dynamic> menuActionHandler(String type) async { Future<dynamic> menuActionHandler(String type) async {
switch (type) { switch (type) {
case 'block': case 'block':
Get.back();
blockUser(); blockUser();
break; break;
case 'watchLater': case 'watchLater':
@ -338,7 +358,10 @@ class MorePanel extends StatelessWidget {
reSrc: 11, reSrc: 11,
); );
SmartDialog.dismiss(); SmartDialog.dismiss();
SmartDialog.showToast(res['msg'] ?? '成功'); if (res['status']) {
blockUserCb?.call(videoItem.owner.mid);
}
SmartDialog.showToast(res['msg']);
}, },
child: const Text('确认'), child: const Text('确认'),
) )

View File

@ -387,9 +387,15 @@ class VideoHttp {
'csrf': await Request.getCsrf(), 'csrf': await Request.getCsrf(),
}); });
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']}; if (act == 5) {
List<int> blackMidsList =
setting.get(SettingBoxKey.blackMidsList, defaultValue: [-1]);
blackMidsList.add(mid);
setting.put(SettingBoxKey.blackMidsList, blackMidsList);
}
return {'status': true, 'data': res.data['data'], 'msg': '成功'};
} else { } else {
return {'status': false, 'data': []}; return {'status': false, 'data': [], 'msg': res.data['message']};
} }
} }

View File

@ -415,6 +415,7 @@ class DynamicMajorModel {
this.type, this.type,
this.courses, this.courses,
this.common, this.common,
this.music,
}); });
DynamicArchiveModel? archive; DynamicArchiveModel? archive;
@ -431,6 +432,7 @@ class DynamicMajorModel {
String? type; String? type;
Map? courses; Map? courses;
Map? common; Map? common;
Map? music;
DynamicMajorModel.fromJson(Map<String, dynamic> json) { DynamicMajorModel.fromJson(Map<String, dynamic> json) {
archive = json['archive'] != null archive = json['archive'] != null
@ -455,6 +457,7 @@ class DynamicMajorModel {
type = json['type']; type = json['type'];
courses = json['courses'] ?? {}; courses = json['courses'] ?? {};
common = json['common'] ?? {}; common = json['common'] ?? {};
music = json['music'] ?? {};
} }
} }

View File

@ -238,6 +238,61 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
), ),
), ),
); );
case 'DYNAMIC_TYPE_MUSIC':
final Map music = item.modules.moduleDynamic.major.music;
return Padding(
padding: const EdgeInsets.only(top: 8),
child: InkWell(
onTap: () {
Get.toNamed('/webview', parameters: {
'url': "https:${music['jump_url']}",
'type': 'url',
'pageTitle': music['title']
});
},
child: Container(
width: double.infinity,
padding:
const EdgeInsets.only(left: 12, top: 10, right: 12, bottom: 10),
color: Theme.of(context).dividerColor.withOpacity(0.08),
child: Row(
children: [
NetworkImgLayer(
width: 45,
height: 45,
src: music['cover'],
),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
music['title'],
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
music['label'],
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
)
],
),
// TextButton(onPressed: () {}, child: Text('123'))
),
),
);
default: default:
return const SizedBox( return const SizedBox(
width: double.infinity, width: double.infinity,

View File

@ -198,7 +198,8 @@ class HistoryItem extends StatelessWidget {
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(
StyleString.imgRadius.x),
color: Colors.black.withOpacity( color: Colors.black.withOpacity(
ctr!.enableMultiple.value && ctr!.enableMultiple.value &&
videoItem.checked videoItem.checked

View File

@ -17,8 +17,7 @@ class LiveRoomController extends GetxController {
double volume = 0.0; double volume = 0.0;
// 静音状态 // 静音状态
RxBool volumeOff = false.obs; RxBool volumeOff = false.obs;
PlPlayerController plPlayerController = PlPlayerController plPlayerController = PlPlayerController(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; late int currentQn;

View File

@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/http/video.dart'; import 'package:pilipala/http/video.dart';
@ -106,4 +107,10 @@ class RcmdController extends GetxController {
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
} }
} }
void blockUserCb(mid) {
videoList.removeWhere((e) => e.owner.mid == mid);
videoList.refresh();
SmartDialog.showToast('已移除相关视频');
}
} }

View File

@ -146,6 +146,7 @@ class _RcmdPageState extends State<RcmdPage>
? VideoCardV( ? VideoCardV(
videoItem: videoList[index], videoItem: videoList[index],
crossAxisCount: crossAxisCount, crossAxisCount: crossAxisCount,
blockUserCb: (mid) => ctr.blockUserCb(mid),
) )
: const VideoCardVSkeleton(); : const VideoCardVSkeleton();
}, },

View File

@ -74,7 +74,7 @@ class VideoDetailController extends GetxController
final scaffoldKey = GlobalKey<ScaffoldState>(); final scaffoldKey = GlobalKey<ScaffoldState>();
RxString bgCover = ''.obs; RxString bgCover = ''.obs;
RxString cover = ''.obs; RxString cover = ''.obs;
PlPlayerController plPlayerController = PlPlayerController.getInstance(); PlPlayerController plPlayerController = PlPlayerController();
late VideoItem firstVideo; late VideoItem firstVideo;
late AudioItem firstAudio; late AudioItem firstAudio;
@ -233,7 +233,7 @@ class VideoDetailController extends GetxController
audio, audio,
seekToTime, seekToTime,
duration, duration,
bool autoplay = true, bool? autoplay,
}) async { }) async {
/// 设置/恢复 屏幕亮度 /// 设置/恢复 屏幕亮度
if (brightness != null) { if (brightness != null) {
@ -266,7 +266,7 @@ class VideoDetailController extends GetxController
cid: cid.value, cid: cid.value,
enableHeart: enableHeart, enableHeart: enableHeart,
isFirstTime: isFirstTime, isFirstTime: isFirstTime,
autoplay: autoplay, autoplay: autoplay ?? autoPlay.value,
); );
/// 开启自动全屏时在player初始化完成后立即传入headerControl /// 开启自动全屏时在player初始化完成后立即传入headerControl

View File

@ -176,7 +176,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
/// 未开启自动播放时触发播放 /// 未开启自动播放时触发播放
Future<void> handlePlay() async { Future<void> handlePlay() async {
await vdCtr.playerInit(); await vdCtr.playerInit(autoplay: true);
plPlayerController = vdCtr.plPlayerController; plPlayerController = vdCtr.plPlayerController;
plPlayerController!.addStatusLister(playerListener); plPlayerController!.addStatusLister(playerListener);
vdCtr.autoPlay.value = true; vdCtr.autoPlay.value = true;
@ -266,7 +266,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
} }
vdCtr.isFirstTime = false; vdCtr.isFirstTime = false;
final bool autoplay = autoPlayEnable; final bool autoplay = autoPlayEnable;
vdCtr.playerInit(autoplay: autoplay); vdCtr.playerInit();
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回 /// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
vdCtr.autoPlay.value = !vdCtr.isShowCover.value; vdCtr.autoPlay.value = !vdCtr.isShowCover.value;

View File

@ -123,6 +123,7 @@ class PlPlayerController {
PreferredSizeWidget? bottomControl; PreferredSizeWidget? bottomControl;
Widget? danmuWidget; Widget? danmuWidget;
late RxList subtitles; late RxList subtitles;
String videoType = 'archive';
/// 数据加载监听 /// 数据加载监听
Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream; Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream;
@ -220,7 +221,7 @@ class PlPlayerController {
Rx<int> get playerCount => _playerCount; Rx<int> get playerCount => _playerCount;
/// ///
Rx<String> get videoType => _videoType; // Rx<String> get videoType => _videoType;
/// 弹幕开关 /// 弹幕开关
Rx<bool> isOpenDanmu = false.obs; Rx<bool> isOpenDanmu = false.obs;
@ -274,8 +275,7 @@ class PlPlayerController {
} }
// 添加一个私有构造函数 // 添加一个私有构造函数
PlPlayerController._() { PlPlayerController._internal(this.videoType) {
_videoType = videoType;
isOpenDanmu.value = isOpenDanmu.value =
setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false); setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
blockTypes = blockTypes =
@ -330,11 +330,11 @@ class PlPlayerController {
} }
// 获取实例 传参 // 获取实例 传参
static PlPlayerController getInstance({ factory PlPlayerController({
String videoType = 'archive', String videoType = 'archive',
}) { }) {
// 如果实例尚未创建,则创建一个新实例 // 如果实例尚未创建,则创建一个新实例
_instance ??= PlPlayerController._(); _instance ??= PlPlayerController._internal(videoType);
if (videoType != 'none') { if (videoType != 'none') {
_instance!._playerCount.value += 1; _instance!._playerCount.value += 1;
_videoType.value = videoType; _videoType.value = videoType;
@ -406,7 +406,7 @@ class PlPlayerController {
if (!_listenersInitialized) { if (!_listenersInitialized) {
startListeners(); startListeners();
} }
await _initializePlayer(seekTo: seekTo, duration: _duration.value); await _initializePlayer(duration: _duration.value);
bool autoEnterFullcreen = bool autoEnterFullcreen =
setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false); setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
if (autoEnterFullcreen && _isFirstTime) { if (autoEnterFullcreen && _isFirstTime) {
@ -443,7 +443,7 @@ class PlPlayerController {
configuration: PlayerConfiguration( configuration: PlayerConfiguration(
// 默认缓存 5M 大小 // 默认缓存 5M 大小
bufferSize: bufferSize:
videoType.value == 'live' ? 32 * 1024 * 1024 : 5 * 1024 * 1024, videoType == 'live' ? 32 * 1024 * 1024 : 5 * 1024 * 1024,
), ),
); );
@ -523,7 +523,6 @@ class PlPlayerController {
// 开始播放 // 开始播放
Future _initializePlayer({ Future _initializePlayer({
Duration seekTo = Duration.zero,
Duration? duration, Duration? duration,
}) async { }) async {
getVideoFit(); getVideoFit();
@ -542,7 +541,7 @@ class PlPlayerController {
} }
/// 设置倍速 /// 设置倍速
if (videoType.value == 'live') { if (videoType == 'live') {
await setPlaybackSpeed(1.0); await setPlaybackSpeed(1.0);
} else { } else {
if (_playbackSpeed.value != 1.0) { if (_playbackSpeed.value != 1.0) {
@ -934,7 +933,7 @@ class PlPlayerController {
/// 设置长按倍速状态 live模式下禁用 /// 设置长按倍速状态 live模式下禁用
void setDoubleSpeedStatus(bool val) { void setDoubleSpeedStatus(bool val) {
if (videoType.value == 'live') { if (videoType == 'live') {
return; return;
} }
if (controlsLock.value) { if (controlsLock.value) {
@ -1016,7 +1015,7 @@ class PlPlayerController {
if (!_enableHeart) { if (!_enableHeart) {
return false; return false;
} }
if (videoType.value == 'live') { if (videoType == 'live') {
return; return;
} }
// 播放状态变化时,更新 // 播放状态变化时,更新
@ -1115,7 +1114,6 @@ class PlPlayerController {
// _buffered.close(); // _buffered.close();
// _showControls.close(); // _showControls.close();
// _controlsLock.close(); // _controlsLock.close();
// playerStatus.status.close(); // playerStatus.status.close();
// dataStatus.status.close(); // dataStatus.status.close();

View File

@ -652,7 +652,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}, },
onDoubleTapDown: (TapDownDetails details) { onDoubleTapDown: (TapDownDetails details) {
// live模式下禁用 锁定时🔒禁用 // live模式下禁用 锁定时🔒禁用
if (_.videoType.value == 'live' || _.controlsLock.value) { if (_.videoType == 'live' || _.controlsLock.value) {
return; return;
} }
final double totalWidth = MediaQuery.sizeOf(context).width; final double totalWidth = MediaQuery.sizeOf(context).width;
@ -679,7 +679,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
/// 水平位置 快进 live模式下禁用 /// 水平位置 快进 live模式下禁用
onHorizontalDragUpdate: (DragUpdateDetails details) { onHorizontalDragUpdate: (DragUpdateDetails details) {
// live模式下禁用 锁定时🔒禁用 // live模式下禁用 锁定时🔒禁用
if (_.videoType.value == 'live' || _.controlsLock.value) { if (_.videoType == 'live' || _.controlsLock.value) {
return; return;
} }
// final double tapPosition = details.localPosition.dx; // final double tapPosition = details.localPosition.dx;
@ -695,7 +695,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
_.onChangedSliderStart(); _.onChangedSliderStart();
}, },
onHorizontalDragEnd: (DragEndDetails details) { onHorizontalDragEnd: (DragEndDetails details) {
if (_.videoType.value == 'live' || _.controlsLock.value) { if (_.videoType == 'live' || _.controlsLock.value) {
return; return;
} }
_.onChangedSliderEnd(); _.onChangedSliderEnd();
@ -826,7 +826,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
return const SizedBox(); return const SizedBox();
} }
if (_.videoType.value == 'live') { if (_.videoType == 'live') {
return const SizedBox(); return const SizedBox();
} }
if (value > max || max <= 0) { if (value > max || max <= 0) {
@ -879,7 +879,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// 锁 // 锁
Obx( Obx(
() => Visibility( () => Visibility(
visible: _.videoType.value != 'live' && _.isFullScreen.value, visible: _.videoType != 'live' && _.isFullScreen.value,
child: Align( child: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: FractionalTranslation( child: FractionalTranslation(

View File

@ -26,7 +26,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
static final List<MediaItem> _item = []; static final List<MediaItem> _item = [];
Box setting = GStrorage.setting; Box setting = GStrorage.setting;
bool enableBackgroundPlay = false; bool enableBackgroundPlay = false;
PlPlayerController player = PlPlayerController.getInstance(); PlPlayerController player = PlPlayerController();
VideoPlayerServiceHandler() { VideoPlayerServiceHandler() {
revalidateSetting(); revalidateSetting();

View File

@ -18,7 +18,7 @@ class AudioSessionHandler {
session.configure(const AudioSessionConfiguration.music()); session.configure(const AudioSessionConfiguration.music());
session.interruptionEventStream.listen((event) { session.interruptionEventStream.listen((event) {
final player = PlPlayerController.getInstance(videoType: 'none'); final player = PlPlayerController(videoType: 'none');
if (event.begin) { if (event.begin) {
if (!player.playerStatus.playing) return; if (!player.playerStatus.playing) return;
switch (event.type) { switch (event.type) {
@ -51,7 +51,7 @@ class AudioSessionHandler {
// 耳机拔出暂停 // 耳机拔出暂停
session.becomingNoisyEventStream.listen((_) { session.becomingNoisyEventStream.listen((_) {
final player = PlPlayerController.getInstance(videoType: 'none'); final player = PlPlayerController(videoType: 'none');
if (player.playerStatus.playing) { if (player.playerStatus.playing) {
player.pause(); player.pause();
} }

View File

@ -89,7 +89,7 @@ class ShutdownTimerService {
return; return;
} }
PlPlayerController plPlayerController = PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'none'); PlPlayerController(videoType: 'none');
if (!exitApp && !waitForPlayingCompleted) { if (!exitApp && !waitForPlayingCompleted) {
if (!plPlayerController.playerStatus.playing) { if (!plPlayerController.playerStatus.playing) {
//仅提示用户 //仅提示用户
@ -124,7 +124,7 @@ class ShutdownTimerService {
} else { } else {
//暂停播放 //暂停播放
PlPlayerController plPlayerController = PlPlayerController plPlayerController =
PlPlayerController.getInstance(videoType: 'none'); PlPlayerController(videoType: 'none');
if (plPlayerController.playerStatus.playing) { if (plPlayerController.playerStatus.playing) {
plPlayerController.pause(); plPlayerController.pause();
waitForPlayingCompleted = true; waitForPlayingCompleted = true;