Merge branch 'main' into fix
This commit is contained in:
@ -20,11 +20,13 @@ import 'network_img_layer.dart';
|
||||
class VideoCardV extends StatelessWidget {
|
||||
final dynamic videoItem;
|
||||
final int crossAxisCount;
|
||||
final Function? blockUserCb;
|
||||
|
||||
const VideoCardV({
|
||||
Key? key,
|
||||
required this.videoItem,
|
||||
required this.crossAxisCount,
|
||||
this.blockUserCb,
|
||||
}) : super(key: key);
|
||||
|
||||
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 {
|
||||
final dynamic videoItem;
|
||||
final int crossAxisCount;
|
||||
const VideoContent(
|
||||
{Key? key, required this.videoItem, required this.crossAxisCount})
|
||||
: super(key: key);
|
||||
final Function? blockUserCb;
|
||||
|
||||
const VideoContent({
|
||||
Key? key,
|
||||
required this.videoItem,
|
||||
required this.crossAxisCount,
|
||||
this.blockUserCb,
|
||||
}) : super(key: key);
|
||||
|
||||
Widget _buildBadge(String text, String type, [double fs = 12]) {
|
||||
return PBadge(
|
||||
@ -241,7 +252,10 @@ class VideoContent extends StatelessWidget {
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) {
|
||||
return MorePanel(videoItem: videoItem);
|
||||
return MorePanel(
|
||||
videoItem: videoItem,
|
||||
blockUserCb: blockUserCb,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -297,11 +311,17 @@ class VideoStat extends StatelessWidget {
|
||||
|
||||
class MorePanel extends StatelessWidget {
|
||||
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 {
|
||||
switch (type) {
|
||||
case 'block':
|
||||
Get.back();
|
||||
blockUser();
|
||||
break;
|
||||
case 'watchLater':
|
||||
@ -338,7 +358,10 @@ class MorePanel extends StatelessWidget {
|
||||
reSrc: 11,
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast(res['msg'] ?? '成功');
|
||||
if (res['status']) {
|
||||
blockUserCb?.call(videoItem.owner.mid);
|
||||
}
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
child: const Text('确认'),
|
||||
)
|
||||
|
@ -387,9 +387,15 @@ class VideoHttp {
|
||||
'csrf': await Request.getCsrf(),
|
||||
});
|
||||
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 {
|
||||
return {'status': false, 'data': []};
|
||||
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,6 +415,7 @@ class DynamicMajorModel {
|
||||
this.type,
|
||||
this.courses,
|
||||
this.common,
|
||||
this.music,
|
||||
});
|
||||
|
||||
DynamicArchiveModel? archive;
|
||||
@ -431,6 +432,7 @@ class DynamicMajorModel {
|
||||
String? type;
|
||||
Map? courses;
|
||||
Map? common;
|
||||
Map? music;
|
||||
|
||||
DynamicMajorModel.fromJson(Map<String, dynamic> json) {
|
||||
archive = json['archive'] != null
|
||||
@ -455,6 +457,7 @@ class DynamicMajorModel {
|
||||
type = json['type'];
|
||||
courses = json['courses'] ?? {};
|
||||
common = json['common'] ?? {};
|
||||
music = json['music'] ?? {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
return const SizedBox(
|
||||
width: double.infinity,
|
||||
|
@ -198,7 +198,8 @@ class HistoryItem extends StatelessWidget {
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: BorderRadius.circular(
|
||||
StyleString.imgRadius.x),
|
||||
color: Colors.black.withOpacity(
|
||||
ctr!.enableMultiple.value &&
|
||||
videoItem.checked
|
||||
|
@ -17,8 +17,7 @@ class LiveRoomController extends GetxController {
|
||||
double volume = 0.0;
|
||||
// 静音状态
|
||||
RxBool volumeOff = false.obs;
|
||||
PlPlayerController plPlayerController =
|
||||
PlPlayerController.getInstance(videoType: 'live');
|
||||
PlPlayerController plPlayerController = PlPlayerController(videoType: 'live');
|
||||
Rx<RoomInfoH5Model> roomInfoH5 = RoomInfoH5Model().obs;
|
||||
late bool enableCDN;
|
||||
late int currentQn;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
@ -106,4 +107,10 @@ class RcmdController extends GetxController {
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||
}
|
||||
}
|
||||
|
||||
void blockUserCb(mid) {
|
||||
videoList.removeWhere((e) => e.owner.mid == mid);
|
||||
videoList.refresh();
|
||||
SmartDialog.showToast('已移除相关视频');
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +146,7 @@ class _RcmdPageState extends State<RcmdPage>
|
||||
? VideoCardV(
|
||||
videoItem: videoList[index],
|
||||
crossAxisCount: crossAxisCount,
|
||||
blockUserCb: (mid) => ctr.blockUserCb(mid),
|
||||
)
|
||||
: const VideoCardVSkeleton();
|
||||
},
|
||||
|
@ -74,7 +74,7 @@ class VideoDetailController extends GetxController
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
RxString bgCover = ''.obs;
|
||||
RxString cover = ''.obs;
|
||||
PlPlayerController plPlayerController = PlPlayerController.getInstance();
|
||||
PlPlayerController plPlayerController = PlPlayerController();
|
||||
|
||||
late VideoItem firstVideo;
|
||||
late AudioItem firstAudio;
|
||||
@ -233,7 +233,7 @@ class VideoDetailController extends GetxController
|
||||
audio,
|
||||
seekToTime,
|
||||
duration,
|
||||
bool autoplay = true,
|
||||
bool? autoplay,
|
||||
}) async {
|
||||
/// 设置/恢复 屏幕亮度
|
||||
if (brightness != null) {
|
||||
@ -266,7 +266,7 @@ class VideoDetailController extends GetxController
|
||||
cid: cid.value,
|
||||
enableHeart: enableHeart,
|
||||
isFirstTime: isFirstTime,
|
||||
autoplay: autoplay,
|
||||
autoplay: autoplay ?? autoPlay.value,
|
||||
);
|
||||
|
||||
/// 开启自动全屏时,在player初始化完成后立即传入headerControl
|
||||
|
@ -176,7 +176,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
/// 未开启自动播放时触发播放
|
||||
Future<void> handlePlay() async {
|
||||
await vdCtr.playerInit();
|
||||
await vdCtr.playerInit(autoplay: true);
|
||||
plPlayerController = vdCtr.plPlayerController;
|
||||
plPlayerController!.addStatusLister(playerListener);
|
||||
vdCtr.autoPlay.value = true;
|
||||
@ -266,7 +266,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
vdCtr.isFirstTime = false;
|
||||
final bool autoplay = autoPlayEnable;
|
||||
vdCtr.playerInit(autoplay: autoplay);
|
||||
vdCtr.playerInit();
|
||||
|
||||
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
||||
vdCtr.autoPlay.value = !vdCtr.isShowCover.value;
|
||||
|
@ -123,6 +123,7 @@ class PlPlayerController {
|
||||
PreferredSizeWidget? bottomControl;
|
||||
Widget? danmuWidget;
|
||||
late RxList subtitles;
|
||||
String videoType = 'archive';
|
||||
|
||||
/// 数据加载监听
|
||||
Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream;
|
||||
@ -220,7 +221,7 @@ class PlPlayerController {
|
||||
Rx<int> get playerCount => _playerCount;
|
||||
|
||||
///
|
||||
Rx<String> get videoType => _videoType;
|
||||
// Rx<String> get videoType => _videoType;
|
||||
|
||||
/// 弹幕开关
|
||||
Rx<bool> isOpenDanmu = false.obs;
|
||||
@ -274,8 +275,7 @@ class PlPlayerController {
|
||||
}
|
||||
|
||||
// 添加一个私有构造函数
|
||||
PlPlayerController._() {
|
||||
_videoType = videoType;
|
||||
PlPlayerController._internal(this.videoType) {
|
||||
isOpenDanmu.value =
|
||||
setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
|
||||
blockTypes =
|
||||
@ -330,11 +330,11 @@ class PlPlayerController {
|
||||
}
|
||||
|
||||
// 获取实例 传参
|
||||
static PlPlayerController getInstance({
|
||||
factory PlPlayerController({
|
||||
String videoType = 'archive',
|
||||
}) {
|
||||
// 如果实例尚未创建,则创建一个新实例
|
||||
_instance ??= PlPlayerController._();
|
||||
_instance ??= PlPlayerController._internal(videoType);
|
||||
if (videoType != 'none') {
|
||||
_instance!._playerCount.value += 1;
|
||||
_videoType.value = videoType;
|
||||
@ -406,7 +406,7 @@ class PlPlayerController {
|
||||
if (!_listenersInitialized) {
|
||||
startListeners();
|
||||
}
|
||||
await _initializePlayer(seekTo: seekTo, duration: _duration.value);
|
||||
await _initializePlayer(duration: _duration.value);
|
||||
bool autoEnterFullcreen =
|
||||
setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
|
||||
if (autoEnterFullcreen && _isFirstTime) {
|
||||
@ -443,7 +443,7 @@ class PlPlayerController {
|
||||
configuration: PlayerConfiguration(
|
||||
// 默认缓存 5M 大小
|
||||
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({
|
||||
Duration seekTo = Duration.zero,
|
||||
Duration? duration,
|
||||
}) async {
|
||||
getVideoFit();
|
||||
@ -542,7 +541,7 @@ class PlPlayerController {
|
||||
}
|
||||
|
||||
/// 设置倍速
|
||||
if (videoType.value == 'live') {
|
||||
if (videoType == 'live') {
|
||||
await setPlaybackSpeed(1.0);
|
||||
} else {
|
||||
if (_playbackSpeed.value != 1.0) {
|
||||
@ -934,7 +933,7 @@ class PlPlayerController {
|
||||
|
||||
/// 设置长按倍速状态 live模式下禁用
|
||||
void setDoubleSpeedStatus(bool val) {
|
||||
if (videoType.value == 'live') {
|
||||
if (videoType == 'live') {
|
||||
return;
|
||||
}
|
||||
if (controlsLock.value) {
|
||||
@ -1016,7 +1015,7 @@ class PlPlayerController {
|
||||
if (!_enableHeart) {
|
||||
return false;
|
||||
}
|
||||
if (videoType.value == 'live') {
|
||||
if (videoType == 'live') {
|
||||
return;
|
||||
}
|
||||
// 播放状态变化时,更新
|
||||
@ -1115,7 +1114,6 @@ class PlPlayerController {
|
||||
// _buffered.close();
|
||||
// _showControls.close();
|
||||
// _controlsLock.close();
|
||||
|
||||
// playerStatus.status.close();
|
||||
// dataStatus.status.close();
|
||||
|
||||
|
@ -652,7 +652,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
},
|
||||
onDoubleTapDown: (TapDownDetails details) {
|
||||
// live模式下禁用 锁定时🔒禁用
|
||||
if (_.videoType.value == 'live' || _.controlsLock.value) {
|
||||
if (_.videoType == 'live' || _.controlsLock.value) {
|
||||
return;
|
||||
}
|
||||
final double totalWidth = MediaQuery.sizeOf(context).width;
|
||||
@ -679,7 +679,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
/// 水平位置 快进 live模式下禁用
|
||||
onHorizontalDragUpdate: (DragUpdateDetails details) {
|
||||
// live模式下禁用 锁定时🔒禁用
|
||||
if (_.videoType.value == 'live' || _.controlsLock.value) {
|
||||
if (_.videoType == 'live' || _.controlsLock.value) {
|
||||
return;
|
||||
}
|
||||
// final double tapPosition = details.localPosition.dx;
|
||||
@ -695,7 +695,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
_.onChangedSliderStart();
|
||||
},
|
||||
onHorizontalDragEnd: (DragEndDetails details) {
|
||||
if (_.videoType.value == 'live' || _.controlsLock.value) {
|
||||
if (_.videoType == 'live' || _.controlsLock.value) {
|
||||
return;
|
||||
}
|
||||
_.onChangedSliderEnd();
|
||||
@ -826,7 +826,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
if (_.videoType.value == 'live') {
|
||||
if (_.videoType == 'live') {
|
||||
return const SizedBox();
|
||||
}
|
||||
if (value > max || max <= 0) {
|
||||
@ -879,7 +879,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
// 锁
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: _.videoType.value != 'live' && _.isFullScreen.value,
|
||||
visible: _.videoType != 'live' && _.isFullScreen.value,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: FractionalTranslation(
|
||||
|
@ -26,7 +26,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
|
||||
static final List<MediaItem> _item = [];
|
||||
Box setting = GStrorage.setting;
|
||||
bool enableBackgroundPlay = false;
|
||||
PlPlayerController player = PlPlayerController.getInstance();
|
||||
PlPlayerController player = PlPlayerController();
|
||||
|
||||
VideoPlayerServiceHandler() {
|
||||
revalidateSetting();
|
||||
|
@ -18,7 +18,7 @@ class AudioSessionHandler {
|
||||
session.configure(const AudioSessionConfiguration.music());
|
||||
|
||||
session.interruptionEventStream.listen((event) {
|
||||
final player = PlPlayerController.getInstance(videoType: 'none');
|
||||
final player = PlPlayerController(videoType: 'none');
|
||||
if (event.begin) {
|
||||
if (!player.playerStatus.playing) return;
|
||||
switch (event.type) {
|
||||
@ -51,7 +51,7 @@ class AudioSessionHandler {
|
||||
|
||||
// 耳机拔出暂停
|
||||
session.becomingNoisyEventStream.listen((_) {
|
||||
final player = PlPlayerController.getInstance(videoType: 'none');
|
||||
final player = PlPlayerController(videoType: 'none');
|
||||
if (player.playerStatus.playing) {
|
||||
player.pause();
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class ShutdownTimerService {
|
||||
return;
|
||||
}
|
||||
PlPlayerController plPlayerController =
|
||||
PlPlayerController.getInstance(videoType: 'none');
|
||||
PlPlayerController(videoType: 'none');
|
||||
if (!exitApp && !waitForPlayingCompleted) {
|
||||
if (!plPlayerController.playerStatus.playing) {
|
||||
//仅提示用户
|
||||
@ -124,7 +124,7 @@ class ShutdownTimerService {
|
||||
} else {
|
||||
//暂停播放
|
||||
PlPlayerController plPlayerController =
|
||||
PlPlayerController.getInstance(videoType: 'none');
|
||||
PlPlayerController(videoType: 'none');
|
||||
if (plPlayerController.playerStatus.playing) {
|
||||
plPlayerController.pause();
|
||||
waitForPlayingCompleted = true;
|
||||
|
Reference in New Issue
Block a user