fix: 自动全屏时headerControl丢失 issues #79
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:floating/floating.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@ -16,6 +18,8 @@ import 'package:pilipala/utils/storage.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:screen_brightness/screen_brightness.dart';
|
||||
|
||||
import 'widgets/header_control.dart';
|
||||
|
||||
class VideoDetailController extends GetxController
|
||||
with GetSingleTickerProviderStateMixin {
|
||||
/// 路由传参
|
||||
@ -76,6 +80,8 @@ class VideoDetailController extends GetxController
|
||||
bool enableHeart = true;
|
||||
var userInfo;
|
||||
late bool isFirstTime = true;
|
||||
Floating? floating;
|
||||
late PreferredSizeWidget headerControl;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -104,6 +110,16 @@ class VideoDetailController extends GetxController
|
||||
enableHeart = false;
|
||||
}
|
||||
danmakuCid.value = cid;
|
||||
|
||||
///
|
||||
if (Platform.isAndroid) {
|
||||
floating = Floating();
|
||||
}
|
||||
headerControl = HeaderControl(
|
||||
controller: plPlayerController,
|
||||
videoDetailCtr: this,
|
||||
floating: floating,
|
||||
);
|
||||
}
|
||||
|
||||
showReplyReplyPanel() {
|
||||
@ -207,6 +223,9 @@ class VideoDetailController extends GetxController
|
||||
isFirstTime: isFirstTime,
|
||||
autoplay: autoplay,
|
||||
);
|
||||
|
||||
/// 开启自动全屏时,在player初始化完成后立即传入headerControl
|
||||
plPlayerController.headerControl = headerControl;
|
||||
}
|
||||
|
||||
// 视频链接
|
||||
|
@ -53,7 +53,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
late Future _futureBuilderFuture;
|
||||
// 自动退出全屏
|
||||
late bool autoExitFullcreen;
|
||||
Floating? floating;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -66,9 +65,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
setting.get(SettingBoxKey.enableAutoExit, defaultValue: false);
|
||||
videoSourceInit();
|
||||
appbarStreamListen();
|
||||
if (Platform.isAndroid) {
|
||||
floating = Floating();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取视频资源,初始化播放器
|
||||
@ -100,7 +96,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
plPlayerController!.triggerFullScreen(status: false);
|
||||
}
|
||||
// 播放完展示控制栏
|
||||
PiPStatus currentStatus = await floating!.pipStatus;
|
||||
PiPStatus currentStatus = await videoDetailController.floating!.pipStatus;
|
||||
if (currentStatus == PiPStatus.disabled) {
|
||||
plPlayerController!.onLockControl(false);
|
||||
}
|
||||
@ -128,8 +124,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
plPlayerController!.removeStatusLister(playerListener);
|
||||
plPlayerController!.dispose();
|
||||
}
|
||||
if (floating != null) {
|
||||
floating!.dispose();
|
||||
if (videoDetailController.floating != null) {
|
||||
videoDetailController.floating!.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
@ -219,13 +215,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
? const SizedBox()
|
||||
: PLVideoPlayer(
|
||||
controller: plPlayerController!,
|
||||
headerControl: HeaderControl(
|
||||
controller:
|
||||
plPlayerController,
|
||||
videoDetailCtr:
|
||||
videoDetailController,
|
||||
floating: floating,
|
||||
),
|
||||
headerControl:
|
||||
videoDetailController
|
||||
.headerControl,
|
||||
danmuWidget: Obx(
|
||||
() => PlDanmaku(
|
||||
key: Key(
|
||||
|
@ -561,14 +561,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
Obx(
|
||||
() => Column(
|
||||
children: [
|
||||
if (widget.headerControl != null)
|
||||
if (widget.headerControl != null || _.headerControl != null)
|
||||
ClipRect(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: AppBarAni(
|
||||
controller: animationController,
|
||||
visible: !_.controlsLock.value && _.showControls.value,
|
||||
position: 'top',
|
||||
child: widget.headerControl!,
|
||||
child: widget.headerControl ?? _.headerControl!,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
|
Reference in New Issue
Block a user