Skip to content

Commit

Permalink
feat: pip改变布局
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Nov 4, 2024
1 parent 8868e75 commit b8282cd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
28 changes: 24 additions & 4 deletions lib/pages/video/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:math';
import 'dart:ui';

import 'package:auto_orientation/auto_orientation.dart';
import 'package:fl_pip/fl_pip.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
Expand Down Expand Up @@ -311,15 +312,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
autoplay: videoDetailController.autoPlay.value);

videoDetailController.autoPlay.value =
!videoDetailController.isShowCover.value;
!videoDetailController.isShowCover.value;
print("autoplay:${videoDetailController.autoPlay.value}");
if (videoDetailController.videoType == SearchType.video) {
final videoIntroController =
Get.find<VideoIntroController>(tag: Get.arguments['heroTag']);
Get.find<VideoIntroController>(tag: Get.arguments['heroTag']);
videoIntroController.videoDetail.refresh();
} else if (videoDetailController.videoType == SearchType.media_bangumi) {
final bangumiIntroController =
Get.find<BangumiIntroController>(tag: Get.arguments['heroTag']);
Get.find<BangumiIntroController>(tag: Get.arguments['heroTag']);
bangumiIntroController.bangumiDetail.refresh();
}

Expand Down Expand Up @@ -558,6 +559,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
children: <Widget>[
// if (isShowing) plPlayer,
plPlayer,

/// 关闭自动播放时 手动播放
if (!videoDetailController
.autoPlay.value) ...<Widget>[
Expand Down Expand Up @@ -688,6 +690,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
child: Stack(children: <Widget>[
// if (isShowing) plPlayer,
plPlayer,

/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
Expand Down Expand Up @@ -781,6 +784,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
child: Stack(children: <Widget>[
// if (isShowing) plPlayer,
plPlayer,

/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
Expand Down Expand Up @@ -875,6 +879,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
children: <Widget>[
// if (isShowing) plPlayer,
plPlayer,

/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
Expand Down Expand Up @@ -974,6 +979,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
children: <Widget>[
// if (isShowing) plPlayer,
plPlayer,

/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
Expand Down Expand Up @@ -1151,14 +1157,28 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
);
Widget autoChoose(Widget childWhenDisabled) {

return PiPBuilder(builder: (PiPStatusInfo? statusInfo) {
print("PiPStatusInfo${statusInfo?.status}");
switch (statusInfo?.status) {
case PiPStatus.enabled:
return childWhenEnabled;
case PiPStatus.disabled:
return childWhenDisabled;
case PiPStatus.unavailable:
return childWhenDisabled;
case null:
return childWhenDisabled;
}
});
// if (Platform.isAndroid) {
// return PiPSwitcher(
// childWhenDisabled: childWhenDisabled,
// childWhenEnabled: childWhenEnabled,
// floating: floating,
// );
// }
return childWhenDisabled;
// return childWhenDisabled;
}

@override
Expand Down
12 changes: 8 additions & 4 deletions lib/pages/video/widgets/header_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ class _HeaderControlState extends State<HeaderControl> {
}
print(widget.controller!.dataSource.videoSource);
print(widget.controller!.dataSource.audioSource);
widget.controller!.controls = false;
FlPiP().enable(
ios: FlPiPiOSConfig(
videoPath:
Expand All @@ -1629,10 +1630,13 @@ class _HeaderControlState extends State<HeaderControl> {
widget.controller!.dataSource.audioSource ?? "",
packageName: null),
android: FlPiPAndroidConfig(
aspectRatio: Rational(
widget.videoDetailCtr!.data.dash!.video!.first.width!,
widget.videoDetailCtr!.data.dash!.video!.first.height!,
)));
aspectRatio: Rational(
widget.videoDetailCtr!.data.dash!.video!.first.width!,
widget
.videoDetailCtr!.data.dash!.video!.first.height!,
),
// createNewEngine: true,
));
// bool canUsePiP = widget.floating != null &&
// await widget.floating!.isPipAvailable;
// widget.controller!.hiddenControls(false);
Expand Down

0 comments on commit b8282cd

Please sign in to comment.