mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-03 17:44:56 +08:00
add pip backward/forward btns
Closes #2251 Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -276,6 +276,7 @@ class PlPlayerController with BlockConfigMixin {
|
||||
}
|
||||
|
||||
late bool _isAutoEnterPip = false;
|
||||
bool get isAutoEnterPip => _isAutoEnterPip;
|
||||
|
||||
static bool get _isCurrVideoPage {
|
||||
final routing = Get.routing;
|
||||
@@ -296,6 +297,8 @@ class PlPlayerController with BlockConfigMixin {
|
||||
autoEnter: autoEnter,
|
||||
width: state.width == 0 ? width : state.width,
|
||||
height: state.height == 0 ? height : state.height,
|
||||
isLive: isLive,
|
||||
isPlaying: playerStatus.isPlaying,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1075,18 +1078,10 @@ class PlPlayerController with BlockConfigMixin {
|
||||
// }
|
||||
// }),
|
||||
// 媒体通知监听
|
||||
if (videoPlayerServiceHandler != null) ...[
|
||||
playerStatus.listen((PlayerStatus event) {
|
||||
videoPlayerServiceHandler!.onStatusChange(
|
||||
event,
|
||||
isBuffering.value,
|
||||
isLive,
|
||||
);
|
||||
}),
|
||||
if (videoPlayerServiceHandler != null)
|
||||
positionSeconds.listen((int event) {
|
||||
videoPlayerServiceHandler!.onPositionChange(Duration(seconds: event));
|
||||
}),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:io' show File;
|
||||
import 'dart:io' show File, Platform;
|
||||
import 'dart:ui' show PlatformDispatcher;
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/grpc/bilibili/app/listener/v1.pb.dart' show DetailItem;
|
||||
@@ -9,6 +10,7 @@ import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/page.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/play_status.dart';
|
||||
import 'package:PiliPlus/utils/android/bindings.g.dart';
|
||||
import 'package:PiliPlus/utils/image_utils.dart';
|
||||
import 'package:PiliPlus/utils/path_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
@@ -120,6 +122,15 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
|
||||
},
|
||||
),
|
||||
);
|
||||
if (Platform.isAndroid &&
|
||||
(AndroidHelper.isPipMode ||
|
||||
PlPlayerController.instance?.isAutoEnterPip == true)) {
|
||||
AndroidHelper.updatePipActions(
|
||||
PlatformDispatcher.instance.engineId!,
|
||||
isLive,
|
||||
playing,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void onStatusChange(PlayerStatus status, bool isBuffering, isLive) {
|
||||
|
||||
@@ -73,13 +73,20 @@ abstract final class PiliAndroidHelper {
|
||||
}
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
static void enterPip(int width, int height, bool autoEnter) =>
|
||||
AndroidHelper.enterPip(
|
||||
width,
|
||||
height,
|
||||
autoEnter,
|
||||
PlatformDispatcher.instance.engineId!,
|
||||
);
|
||||
static void enterPip(
|
||||
int width,
|
||||
int height, {
|
||||
required bool autoEnter,
|
||||
required bool isLive,
|
||||
required bool isPlaying,
|
||||
}) => AndroidHelper.enterPip(
|
||||
PlatformDispatcher.instance.engineId!,
|
||||
width,
|
||||
height,
|
||||
autoEnter,
|
||||
isLive,
|
||||
isPlaying,
|
||||
);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
static void disableAutoEnterPip() =>
|
||||
|
||||
@@ -447,7 +447,7 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
|
||||
static final _id_enterPip = _class.staticMethodId(
|
||||
r'enterPip',
|
||||
r'(IIZJ)V',
|
||||
r'(JIIZZZ)V',
|
||||
);
|
||||
|
||||
static final _enterPip =
|
||||
@@ -457,7 +457,14 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<
|
||||
(jni$_.Int32, jni$_.Int32, jni$_.Int32, jni$_.Int64)
|
||||
(
|
||||
jni$_.Int64,
|
||||
jni$_.Int32,
|
||||
jni$_.Int32,
|
||||
jni$_.Int32,
|
||||
jni$_.Int32,
|
||||
jni$_.Int32,
|
||||
)
|
||||
>,
|
||||
)
|
||||
>
|
||||
@@ -470,24 +477,71 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void enterPip(int width, int height, boolean autoEnter, long engineId)`
|
||||
/// from: `static public void enterPip(long engineId, int width, int height, boolean autoEnter, boolean isLive, boolean isPlaying)`
|
||||
static void enterPip(
|
||||
core$_.int engineId,
|
||||
core$_.int width,
|
||||
core$_.int height,
|
||||
core$_.bool autoEnter,
|
||||
core$_.int engineId,
|
||||
core$_.bool isLive,
|
||||
core$_.bool isPlaying,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
_enterPip(
|
||||
_$$classRef.pointer,
|
||||
_id_enterPip.pointer,
|
||||
engineId,
|
||||
width,
|
||||
height,
|
||||
autoEnter ? 1 : 0,
|
||||
isLive ? 1 : 0,
|
||||
isPlaying ? 1 : 0,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_updatePipActions = _class.staticMethodId(
|
||||
r'updatePipActions',
|
||||
r'(JZZ)V',
|
||||
);
|
||||
|
||||
static final _updatePipActions =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<(jni$_.Int64, jni$_.Int32, jni$_.Int32)>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void updatePipActions(long engineId, boolean isLive, boolean isPlaying)`
|
||||
static void updatePipActions(
|
||||
core$_.int engineId,
|
||||
core$_.bool isLive,
|
||||
core$_.bool isPlaying,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
_updatePipActions(
|
||||
_$$classRef.pointer,
|
||||
_id_updatePipActions.pointer,
|
||||
engineId,
|
||||
isLive ? 1 : 0,
|
||||
isPlaying ? 1 : 0,
|
||||
).check();
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,13 @@ abstract final class PageUtils {
|
||||
return (min <= aspectRatio) && (aspectRatio <= max);
|
||||
}
|
||||
|
||||
static void enterPip({int? width, int? height, bool autoEnter = false}) {
|
||||
static void enterPip({
|
||||
int? width,
|
||||
int? height,
|
||||
bool autoEnter = false,
|
||||
required bool isLive,
|
||||
required bool isPlaying,
|
||||
}) {
|
||||
if (width != null &&
|
||||
height != null &&
|
||||
!_fitsInAndroidRequirements(width, height)) {
|
||||
@@ -205,7 +211,13 @@ abstract final class PageUtils {
|
||||
height = 9;
|
||||
}
|
||||
}
|
||||
PiliAndroidHelper.enterPip(width ?? 16, height ?? 9, autoEnter);
|
||||
PiliAndroidHelper.enterPip(
|
||||
width ?? 16,
|
||||
height ?? 9,
|
||||
autoEnter: autoEnter,
|
||||
isLive: isLive,
|
||||
isPlaying: isPlaying,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> pushDynDetail(
|
||||
|
||||
Reference in New Issue
Block a user