mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-04 16:20:14 +08:00
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
@@ -48,7 +47,6 @@ import 'package:PiliPlus/utils/video_utils.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||
import 'package:floating/floating.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:flutter_volume_controller/flutter_volume_controller.dart';
|
||||
@@ -103,7 +101,6 @@ class VideoDetailController extends GetxController
|
||||
// 亮度
|
||||
double? brightness;
|
||||
|
||||
Floating? floating;
|
||||
late final headerCtrKey = GlobalKey<HeaderControlState>();
|
||||
|
||||
Box get setting => GStorage.setting;
|
||||
@@ -287,10 +284,6 @@ class VideoDetailController extends GetxController
|
||||
if (autoPlay.value) isShowCover.value = false;
|
||||
danmakuCid.value = cid.value;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
floating = Floating();
|
||||
}
|
||||
|
||||
// 预设的解码格式
|
||||
cacheDecode = setting.get(SettingBoxKey.defaultDecode,
|
||||
defaultValue: VideoDecodeFormatType.values.last.code);
|
||||
@@ -1109,6 +1102,8 @@ class VideoDetailController extends GetxController
|
||||
}
|
||||
setSubtitle(vttSubtitlesIndex.value);
|
||||
},
|
||||
width: data.dash!.video!.first.width,
|
||||
height: data.dash!.video!.first.height,
|
||||
);
|
||||
|
||||
initSkip();
|
||||
@@ -1121,9 +1116,7 @@ class VideoDetailController extends GetxController
|
||||
_getDmTrend();
|
||||
}
|
||||
|
||||
if (defaultST != null) {
|
||||
defaultST = null;
|
||||
}
|
||||
defaultST = null;
|
||||
}
|
||||
|
||||
bool isQuerying = false;
|
||||
|
||||
@@ -86,7 +86,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
late bool autoExitFullscreen;
|
||||
late bool autoPlayEnable;
|
||||
late bool enableVerticalExpand;
|
||||
late bool autoPiP;
|
||||
late bool pipNoDanmaku;
|
||||
late bool removeSafeArea;
|
||||
bool isShowing = true;
|
||||
@@ -142,7 +141,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
setting.get(SettingBoxKey.enableAutoExit, defaultValue: true);
|
||||
autoPlayEnable =
|
||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: false);
|
||||
autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
||||
pipNoDanmaku = setting.get(SettingBoxKey.pipNoDanmaku, defaultValue: false);
|
||||
enableVerticalExpand =
|
||||
setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false);
|
||||
@@ -151,17 +149,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
if (removeSafeArea) hideStatusBar();
|
||||
videoSourceInit();
|
||||
autoScreen();
|
||||
if (Platform.isAndroid) {
|
||||
Utils.channel.setMethodCallHandler((call) async {
|
||||
if (call.method == 'onUserLeaveHint') {
|
||||
if (autoPiP &&
|
||||
plPlayerController?.playerStatus.status.value ==
|
||||
PlayerStatus.playing) {
|
||||
enterPip();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (videoDetailController.showReply) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
@@ -276,9 +263,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
}
|
||||
}
|
||||
// 播放完展示控制栏
|
||||
if (videoDetailController.floating != null && !notExitFlag) {
|
||||
PiPStatus currentStatus =
|
||||
await videoDetailController.floating!.pipStatus;
|
||||
if (Platform.isAndroid && !notExitFlag) {
|
||||
PiPStatus currentStatus = await Floating().pipStatus;
|
||||
if (currentStatus == PiPStatus.disabled) {
|
||||
plPlayerController!.onLockControl(false);
|
||||
}
|
||||
@@ -454,17 +440,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
: Theme.of(context);
|
||||
}
|
||||
|
||||
void enterPip() {
|
||||
if (Get.currentRoute.startsWith('/video') &&
|
||||
videoDetailController.floating != null) {
|
||||
PageUtils.enterPip(
|
||||
videoDetailController.floating!,
|
||||
videoDetailController.data.dash!.video!.first.width!,
|
||||
videoDetailController.data.dash!.video!.first.height!,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void animListener() {
|
||||
if (videoDetailController.animationController.isForwardOrCompleted) {
|
||||
cal();
|
||||
@@ -1413,7 +1388,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
key: videoDetailController.headerCtrKey,
|
||||
controller: videoDetailController.plPlayerController,
|
||||
videoDetailCtr: videoDetailController,
|
||||
floating: videoDetailController.floating,
|
||||
heroTag: heroTag,
|
||||
),
|
||||
danmuWidget: Obx(
|
||||
@@ -1431,11 +1405,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
|
||||
Widget autoChoose(Widget childWhenDisabled) {
|
||||
if (Platform.isAndroid) {
|
||||
return PiPSwitcher(
|
||||
getChildWhenDisabled: () => childWhenDisabled,
|
||||
getChildWhenEnabled: () => childWhenEnabled,
|
||||
floating: videoDetailController.floating,
|
||||
);
|
||||
return Floating().isPipMode ? childWhenEnabled : childWhenDisabled;
|
||||
}
|
||||
return childWhenDisabled;
|
||||
}
|
||||
|
||||
@@ -47,13 +47,11 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
|
||||
const HeaderControl({
|
||||
required this.controller,
|
||||
required this.videoDetailCtr,
|
||||
this.floating,
|
||||
required this.heroTag,
|
||||
super.key,
|
||||
});
|
||||
final PlPlayerController controller;
|
||||
final VideoDetailController videoDetailCtr;
|
||||
final Floating? floating;
|
||||
final String heroTag;
|
||||
|
||||
@override
|
||||
@@ -2118,8 +2116,7 @@ class HeaderControlState extends State<HeaderControl> {
|
||||
padding: WidgetStateProperty.all(EdgeInsets.zero),
|
||||
),
|
||||
onPressed: () async {
|
||||
bool canUsePiP = widget.floating != null &&
|
||||
await widget.floating!.isPipAvailable;
|
||||
bool canUsePiP = await Floating().isPipAvailable;
|
||||
widget.controller.hiddenControls(false);
|
||||
if (canUsePiP) {
|
||||
bool enableBackgroundPlay = setting.get(
|
||||
@@ -2189,10 +2186,9 @@ class HeaderControlState extends State<HeaderControl> {
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
PageUtils.enterPip(
|
||||
widget.floating!,
|
||||
widget
|
||||
width: widget
|
||||
.videoDetailCtr.data.dash!.video!.first.width!,
|
||||
widget
|
||||
height: widget
|
||||
.videoDetailCtr.data.dash!.video!.first.height!,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user