mod: 播放器实例销毁、页面层级
This commit is contained in:
@ -1,57 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class AppBarAni extends StatelessWidget implements PreferredSizeWidget {
|
|
||||||
const AppBarAni({
|
|
||||||
required this.child,
|
|
||||||
required this.controller,
|
|
||||||
required this.visible,
|
|
||||||
this.position,
|
|
||||||
Key? key,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
final PreferredSizeWidget child;
|
|
||||||
final AnimationController controller;
|
|
||||||
final bool visible;
|
|
||||||
final String? position;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Size get preferredSize => child.preferredSize;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
visible ? controller.reverse() : controller.forward();
|
|
||||||
return SlideTransition(
|
|
||||||
position: Tween<Offset>(
|
|
||||||
begin: Offset.zero,
|
|
||||||
end: Offset(0, position! == 'top' ? -1 : 1),
|
|
||||||
).animate(CurvedAnimation(
|
|
||||||
parent: controller,
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
)),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: position! == 'top'
|
|
||||||
? const LinearGradient(
|
|
||||||
begin: Alignment.bottomCenter,
|
|
||||||
end: Alignment.topCenter,
|
|
||||||
colors: <Color>[
|
|
||||||
Colors.transparent,
|
|
||||||
Colors.black45,
|
|
||||||
],
|
|
||||||
tileMode: TileMode.clamp,
|
|
||||||
)
|
|
||||||
: const LinearGradient(
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter,
|
|
||||||
colors: <Color>[
|
|
||||||
Colors.transparent,
|
|
||||||
Colors.black45,
|
|
||||||
],
|
|
||||||
tileMode: TileMode.mirror,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -483,7 +483,11 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
size: 15,
|
size: 15,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
fuc: () => Get.offAll(const MainApp()),
|
fuc: () {
|
||||||
|
// 销毁播放器实例
|
||||||
|
widget.controller!.dispose(type: 'all');
|
||||||
|
Get.offAll(const MainApp());
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// ComBtn(
|
// ComBtn(
|
||||||
|
|||||||
@ -678,11 +678,13 @@ class PlPlayerController {
|
|||||||
videoFitChangedTimer?.cancel();
|
videoFitChangedTimer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> dispose() async {
|
Future<void> dispose({String type = 'single'}) async {
|
||||||
// 每次减1,最后销毁
|
// 每次减1,最后销毁
|
||||||
_playerCount.value -= 1;
|
if (type == 'single') {
|
||||||
if (playerCount.value > 0) {
|
_playerCount.value -= 1;
|
||||||
return;
|
if (playerCount.value > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import 'package:get/get.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:media_kit/media_kit.dart';
|
import 'package:media_kit/media_kit.dart';
|
||||||
import 'package:media_kit_video/media_kit_video.dart';
|
import 'package:media_kit_video/media_kit_video.dart';
|
||||||
import 'package:pilipala/common/widgets/app_bar_ani.dart';
|
|
||||||
import 'package:pilipala/plugin/pl_player/controller.dart';
|
import 'package:pilipala/plugin/pl_player/controller.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/duration.dart';
|
import 'package:pilipala/plugin/pl_player/models/duration.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/fullscreen_mode.dart';
|
import 'package:pilipala/plugin/pl_player/models/fullscreen_mode.dart';
|
||||||
@ -20,6 +19,7 @@ import 'package:screen_brightness/screen_brightness.dart';
|
|||||||
import 'package:volume_controller/volume_controller.dart';
|
import 'package:volume_controller/volume_controller.dart';
|
||||||
|
|
||||||
import 'utils/fullscreen.dart';
|
import 'utils/fullscreen.dart';
|
||||||
|
import 'widgets/app_bar_ani.dart';
|
||||||
import 'widgets/backward_seek.dart';
|
import 'widgets/backward_seek.dart';
|
||||||
import 'widgets/bottom_control.dart';
|
import 'widgets/bottom_control.dart';
|
||||||
import 'widgets/common_btn.dart';
|
import 'widgets/common_btn.dart';
|
||||||
@ -453,6 +453,24 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
Obx(() {
|
||||||
|
if (_.buffered.value == Duration.zero) {
|
||||||
|
return Positioned.fill(
|
||||||
|
child: Container(
|
||||||
|
color: Colors.black,
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/loading.gif',
|
||||||
|
height: 25,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
/// 手势
|
/// 手势
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
left: 16,
|
left: 16,
|
||||||
@ -675,23 +693,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Obx(() {
|
|
||||||
if (_.buffered.value == Duration.zero) {
|
|
||||||
return Positioned.fill(
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: Center(
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/images/loading.gif',
|
|
||||||
height: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
/// 点击 快进/快退
|
/// 点击 快进/快退
|
||||||
if (_mountSeekBackwardButton || _mountSeekForwardButton)
|
if (_mountSeekBackwardButton || _mountSeekForwardButton)
|
||||||
|
|||||||
Reference in New Issue
Block a user