mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: pip
Closes #57 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -16,7 +16,8 @@ class MainActivity : AudioServiceActivity() {
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
methodChannel = MethodChannel(flutterEngine!!.getDartExecutor()!!.getBinaryMessenger(), CHANNEL)
|
||||
|
||||
methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "pilipalax")
|
||||
methodChannel.setMethodCallHandler { call, result ->
|
||||
if (call.method == "back") {
|
||||
back()
|
||||
@@ -53,10 +54,6 @@ class MainActivity : AudioServiceActivity() {
|
||||
methodChannel.invokeMethod("onUserLeaveHint", null)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val CHANNEL = "onUserLeaveHint"
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||
MethodChannel(
|
||||
@@ -108,7 +108,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
ScreenBrightness().resetApplicationScreenBrightness();
|
||||
PlPlayerController.setPlayCallBack(null);
|
||||
_liveRoomController.msgStream?.close();
|
||||
floating?.dispose();
|
||||
// floating?.dispose();
|
||||
_node.dispose();
|
||||
plPlayerController.dispose();
|
||||
_ctr.dispose();
|
||||
@@ -442,8 +442,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
});
|
||||
if (Platform.isAndroid) {
|
||||
return PiPSwitcher(
|
||||
childWhenDisabled: childWhenDisabled,
|
||||
childWhenEnabled: videoPlayerPanel,
|
||||
getChildWhenDisabled: () => childWhenDisabled,
|
||||
getChildWhenEnabled: () => videoPlayerPanel,
|
||||
floating: floating,
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPalaX/grpc/grpc_client.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -155,7 +156,7 @@ class _MainAppState extends State<MainApp>
|
||||
_mainController.bottomBarStream.add(true);
|
||||
} else {
|
||||
if (Platform.isAndroid) {
|
||||
const MethodChannel("onUserLeaveHint").invokeMethod('back');
|
||||
Utils.channel.invokeMethod('back');
|
||||
} else {
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
late final _introController = ScrollController();
|
||||
late String heroTag;
|
||||
|
||||
PlayerStatus playerStatus = PlayerStatus.playing;
|
||||
double doubleOffset = 0;
|
||||
|
||||
late Future _futureBuilderFuture;
|
||||
@@ -83,11 +82,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
late bool pipNoDanmaku;
|
||||
late bool removeSafeArea;
|
||||
// late bool showStatusBarBackgroundColor;
|
||||
final Floating floating = Floating();
|
||||
// final Floating floating = Floating();
|
||||
// 生命周期监听
|
||||
// late final AppLifecycleListener _lifecycleListener;
|
||||
bool isShowing = true;
|
||||
late final MethodChannel onUserLeaveHintListener;
|
||||
// StreamSubscription<Duration>? _bufferedListener;
|
||||
bool get isFullScreen => plPlayerController?.isFullScreen.value ?? false;
|
||||
|
||||
@@ -166,13 +164,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
appbarStreamListen();
|
||||
// lifecycleListener();
|
||||
autoScreen();
|
||||
onUserLeaveHintListener = const MethodChannel("onUserLeaveHint");
|
||||
onUserLeaveHintListener.setMethodCallHandler((call) async {
|
||||
Utils.channel.setMethodCallHandler((call) async {
|
||||
if (call.method == 'onUserLeaveHint') {
|
||||
if (autoPiP &&
|
||||
plPlayerController != null &&
|
||||
playerStatus == PlayerStatus.playing) {
|
||||
autoEnterPip();
|
||||
plPlayerController?.playerStatus.status.value ==
|
||||
PlayerStatus.playing) {
|
||||
enterPip();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -234,7 +231,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
|
||||
// 播放器状态监听
|
||||
void playerListener(PlayerStatus? status) async {
|
||||
playerStatus = status!;
|
||||
if (status == PlayerStatus.completed) {
|
||||
shutdownTimerService.handleWaitingFinished();
|
||||
bool notExitFlag = false;
|
||||
@@ -345,8 +341,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
videoDetailController.positionSubscription?.cancel();
|
||||
videoIntroController.canelTimer();
|
||||
appbarStream.close();
|
||||
floating.dispose();
|
||||
videoDetailController.floating?.dispose();
|
||||
// floating.dispose();
|
||||
// videoDetailController.floating?.dispose();
|
||||
videoIntroController.videoDetail.close();
|
||||
videoDetailController.cid.close();
|
||||
if (!horizontalScreen) {
|
||||
@@ -487,11 +483,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// }
|
||||
// }
|
||||
|
||||
void autoEnterPip() {
|
||||
final String routePath = Get.currentRoute;
|
||||
|
||||
if (autoPiP && routePath.startsWith('/video')) {
|
||||
floating.enable(
|
||||
void enterPip() {
|
||||
if (Get.currentRoute.startsWith('/video')) {
|
||||
videoDetailController.floating?.enable(
|
||||
EnableManual(
|
||||
aspectRatio: Rational(
|
||||
videoDetailController.data.dash!.video!.first.width!,
|
||||
@@ -1117,9 +1111,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
Widget autoChoose(Widget childWhenDisabled) {
|
||||
if (Platform.isAndroid) {
|
||||
return PiPSwitcher(
|
||||
childWhenDisabled: childWhenDisabled,
|
||||
childWhenEnabled: childWhenEnabled,
|
||||
floating: floating,
|
||||
getChildWhenDisabled: () => childWhenDisabled,
|
||||
getChildWhenEnabled: () => childWhenEnabled,
|
||||
floating: videoDetailController.floating,
|
||||
);
|
||||
}
|
||||
return childWhenDisabled;
|
||||
|
||||
@@ -99,7 +99,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.floating?.dispose();
|
||||
// widget.floating?.dispose();
|
||||
// fullScreenStatusListener.cancel();
|
||||
clock?.cancel();
|
||||
super.dispose();
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:canvas_danmaku/canvas_danmaku.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -1291,6 +1292,7 @@ class PlPlayerController {
|
||||
return;
|
||||
}
|
||||
_playerCount.value = 0;
|
||||
Utils.channel.setMethodCallHandler(null);
|
||||
pause();
|
||||
try {
|
||||
_timer?.cancel();
|
||||
|
||||
@@ -33,6 +33,8 @@ import 'package:html/parser.dart' as html_parser;
|
||||
class Utils {
|
||||
static final Random random = Random();
|
||||
|
||||
static const channel = MethodChannel("pilipalax");
|
||||
|
||||
static Future<dynamic> getWwebid(mid) async {
|
||||
try {
|
||||
dynamic response =
|
||||
|
||||
@@ -582,7 +582,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: version-3
|
||||
resolved-ref: b9a19d54defde1819bdfe8f26b950928b0e8a592
|
||||
resolved-ref: "202a46c31bc2c101b254f559115e47661cdb2479"
|
||||
url: "https://github.com/bggRGjQaUbCoE/floating.git"
|
||||
source: git
|
||||
version: "3.0.0"
|
||||
|
||||
Reference in New Issue
Block a user