mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -44,7 +44,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
|
||||
bool isShowCover = true;
|
||||
bool isPlay = true;
|
||||
Floating? floating;
|
||||
|
||||
StreamSubscription? _listener;
|
||||
|
||||
@@ -69,9 +68,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
tag: heroTag,
|
||||
);
|
||||
PlPlayerController.setPlayCallBack(playCallBack);
|
||||
if (Platform.isAndroid) {
|
||||
floating = Floating();
|
||||
}
|
||||
videoSourceInit();
|
||||
_futureBuilderFuture = _liveRoomController.queryLiveInfo();
|
||||
plPlayerController
|
||||
@@ -145,7 +141,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
|
||||
final GlobalKey videoPlayerKey = GlobalKey();
|
||||
final GlobalKey playerKey = GlobalKey();
|
||||
double? padding;
|
||||
|
||||
Widget videoPlayerPanel({Color? fill, Alignment? alignment}) {
|
||||
return PopScope(
|
||||
@@ -167,7 +162,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
plPlayerController: plPlayerController,
|
||||
headerControl: LiveHeaderControl(
|
||||
plPlayerController: plPlayerController,
|
||||
floating: floating,
|
||||
onSendDanmaku: onSendDanmaku,
|
||||
),
|
||||
bottomControl: BottomControl(
|
||||
@@ -243,7 +237,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
top: false,
|
||||
top: !isFullScreen,
|
||||
left: !isFullScreen,
|
||||
right: !isFullScreen,
|
||||
bottom: false,
|
||||
@@ -251,10 +245,6 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
? Obx(
|
||||
() {
|
||||
if (_liveRoomController.isPortrait.value) {
|
||||
if (padding == null) {
|
||||
final padding = MediaQuery.paddingOf(context);
|
||||
this.padding = padding.bottom + padding.top;
|
||||
}
|
||||
return _buildPP;
|
||||
}
|
||||
return _buildPH;
|
||||
@@ -284,52 +274,42 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
children: [
|
||||
_buildAppBar,
|
||||
Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Obx(
|
||||
() => Container(
|
||||
color: Colors.black,
|
||||
width: Get.width,
|
||||
margin: isFullScreen
|
||||
? null
|
||||
: EdgeInsets.only(
|
||||
top: 56 + MediaQuery.paddingOf(context).top,
|
||||
),
|
||||
height: isFullScreen
|
||||
? Get.height -
|
||||
(context.orientation == Orientation.landscape
|
||||
? 0
|
||||
: MediaQuery.paddingOf(context).top)
|
||||
: Get.height - 56 - 85 - padding!,
|
||||
: const EdgeInsets.only(top: 56),
|
||||
color: Colors.black,
|
||||
child: videoPlayerPanel(
|
||||
alignment: isFullScreen ? null : Alignment.topCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Obx(
|
||||
() => isFullScreen
|
||||
? const SizedBox.shrink()
|
||||
: Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 125 + MediaQuery.paddingOf(context).bottom,
|
||||
bottom: 55,
|
||||
child: SizedBox(
|
||||
height: 125,
|
||||
child: _buildChatWidget(true),
|
||||
),
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => isFullScreen
|
||||
? const SizedBox.shrink()
|
||||
: Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: _buildInputWidget,
|
||||
],
|
||||
),
|
||||
),
|
||||
Obx(() =>
|
||||
isFullScreen ? const SizedBox.shrink() : _buildInputWidget),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -341,12 +321,9 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
return OrientationBuilder(
|
||||
builder: (BuildContext context, Orientation orientation) {
|
||||
if (Platform.isAndroid) {
|
||||
return PiPSwitcher(
|
||||
getChildWhenDisabled: () =>
|
||||
childWhenDisabled(orientation == Orientation.portrait),
|
||||
getChildWhenEnabled: () => videoPlayerPanel(),
|
||||
floating: floating,
|
||||
);
|
||||
return Floating().isPipMode
|
||||
? videoPlayerPanel()
|
||||
: childWhenDisabled(orientation == Orientation.portrait);
|
||||
} else {
|
||||
return childWhenDisabled(orientation == Orientation.portrait);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,10 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart
|
||||
class LiveHeaderControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
const LiveHeaderControl({
|
||||
required this.plPlayerController,
|
||||
this.floating,
|
||||
required this.onSendDanmaku,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final Floating? floating;
|
||||
final PlPlayerController plPlayerController;
|
||||
final VoidCallback onSendDanmaku;
|
||||
|
||||
@@ -77,9 +75,15 @@ class LiveHeaderControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
),
|
||||
onPressed: () async {
|
||||
try {
|
||||
if ((await floating?.isPipAvailable) == true) {
|
||||
var floating = Floating();
|
||||
if ((await floating.isPipAvailable) == true) {
|
||||
plPlayerController.hiddenControls(false);
|
||||
floating!.enable(const EnableManual());
|
||||
floating.enable(
|
||||
plPlayerController.direction.value == 'vertical'
|
||||
? const EnableManual(
|
||||
aspectRatio: Rational.vertical())
|
||||
: const EnableManual(),
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
},
|
||||
|
||||
@@ -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,10 +1116,8 @@ class VideoDetailController extends GetxController
|
||||
_getDmTrend();
|
||||
}
|
||||
|
||||
if (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!,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart' show PageUtils;
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:canvas_danmaku/canvas_danmaku.dart';
|
||||
@@ -116,6 +117,8 @@ class PlPlayerController {
|
||||
dynamic _seasonId;
|
||||
dynamic _subType;
|
||||
int _heartDuration = 0;
|
||||
int? width;
|
||||
int? height;
|
||||
|
||||
late DataSource dataSource;
|
||||
|
||||
@@ -243,6 +246,15 @@ class PlPlayerController {
|
||||
/// 弹幕开关
|
||||
RxBool isOpenDanmu = false.obs;
|
||||
|
||||
bool autoPiP =
|
||||
GStorage.setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
||||
|
||||
void enterPip() {
|
||||
if (Get.currentRoute.startsWith('/video')) {
|
||||
PageUtils.enterPip(width: width, height: height);
|
||||
}
|
||||
}
|
||||
|
||||
/// 弹幕权重
|
||||
int danmakuWeight = 0;
|
||||
late RuleFilter filters;
|
||||
@@ -486,6 +498,16 @@ class PlPlayerController {
|
||||
enableHeart = false;
|
||||
}
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
Utils.channel.setMethodCallHandler((call) async {
|
||||
if (call.method == 'onUserLeaveHint') {
|
||||
if (autoPiP && playerStatus.status.value == PlayerStatus.playing) {
|
||||
enterPip();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
|
||||
// if (status == PlayerStatus.playing) {
|
||||
// WakelockPlus.enable();
|
||||
@@ -520,8 +542,8 @@ class PlPlayerController {
|
||||
Duration? seekTo,
|
||||
// 初始化播放速度
|
||||
double speed = 1.0,
|
||||
double? width,
|
||||
double? height,
|
||||
int? width,
|
||||
int? height,
|
||||
Duration? duration,
|
||||
// 方向
|
||||
String? direction,
|
||||
@@ -534,6 +556,8 @@ class PlPlayerController {
|
||||
VoidCallback? callback,
|
||||
}) async {
|
||||
try {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.dataSource = dataSource;
|
||||
this.segmentList.value = segmentList ?? <Segment>[];
|
||||
this.viewPointList.value = viewPointList ?? <Segment>[];
|
||||
@@ -568,8 +592,8 @@ class PlPlayerController {
|
||||
return;
|
||||
}
|
||||
// 配置Player 音轨、字幕等等
|
||||
_videoPlayerController = await _createVideoController(
|
||||
dataSource, _looping, width, height, seekTo);
|
||||
_videoPlayerController =
|
||||
await _createVideoController(dataSource, _looping, seekTo);
|
||||
callback?.call();
|
||||
// 获取视频时长 00:00
|
||||
_duration.value = duration ?? _videoPlayerController!.state.duration;
|
||||
@@ -676,8 +700,6 @@ class PlPlayerController {
|
||||
Future<Player> _createVideoController(
|
||||
DataSource dataSource,
|
||||
PlaylistMode looping,
|
||||
double? width,
|
||||
double? height,
|
||||
Duration? seekTo,
|
||||
) async {
|
||||
// 每次配置时先移除监听
|
||||
|
||||
@@ -330,9 +330,10 @@ class PageUtils {
|
||||
);
|
||||
}
|
||||
|
||||
static void enterPip(Floating floating, int width, int height) {
|
||||
static void enterPip({int? width, int? height}) {
|
||||
if (width != null && height != null) {
|
||||
Rational aspectRatio = Rational(width, height);
|
||||
floating.enable(
|
||||
Floating().enable(
|
||||
EnableManual(
|
||||
aspectRatio: aspectRatio.fitsInAndroidRequirements
|
||||
? aspectRatio
|
||||
@@ -341,6 +342,9 @@ class PageUtils {
|
||||
: const Rational.landscape(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Floating().enable(const EnableManual());
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> pushDynDetail(DynamicItemModel item, floor,
|
||||
|
||||
@@ -607,7 +607,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: version-3
|
||||
resolved-ref: "44bd7a589f199e0b8f7f5bb1a6df08579079c570"
|
||||
resolved-ref: "929e9ec1312d9d1b4755d7589dd53db5b4d6d50d"
|
||||
url: "https://github.com/bggRGjQaUbCoE/floating.git"
|
||||
source: git
|
||||
version: "3.0.0"
|
||||
|
||||
Reference in New Issue
Block a user