@ -4,7 +4,7 @@ import 'package:pilipala/http/video.dart';
|
|||||||
|
|
||||||
class ReleatedController extends GetxController {
|
class ReleatedController extends GetxController {
|
||||||
// 视频aid
|
// 视频aid
|
||||||
String bvid = Get.parameters['bvid']!;
|
String bvid = Get.parameters['bvid'] ?? "";
|
||||||
// 推荐视频列表
|
// 推荐视频列表
|
||||||
List relatedVideoList = [];
|
List relatedVideoList = [];
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
final Floating floating = Floating();
|
final Floating floating = Floating();
|
||||||
// 生命周期监听
|
// 生命周期监听
|
||||||
late final AppLifecycleListener _lifecycleListener;
|
late final AppLifecycleListener _lifecycleListener;
|
||||||
|
bool isShowing = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -216,15 +217,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoIntroController.isPaused = true;
|
videoIntroController.isPaused = true;
|
||||||
plPlayerController!.removeStatusLister(playerListener);
|
plPlayerController!.removeStatusLister(playerListener);
|
||||||
plPlayerController!.pause();
|
plPlayerController!.pause();
|
||||||
plPlayerController!.danmakuController?.pause();
|
|
||||||
plPlayerController!.danmakuController?.clear();
|
|
||||||
}
|
}
|
||||||
|
setState(() => isShowing = false);
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// 返回当前页面时
|
// 返回当前页面时
|
||||||
void didPopNext() async {
|
void didPopNext() async {
|
||||||
|
setState(() => isShowing = true);
|
||||||
videoDetailController.isFirstTime = false;
|
videoDetailController.isFirstTime = false;
|
||||||
final bool autoplay = autoPlayEnable;
|
final bool autoplay = autoPlayEnable;
|
||||||
videoDetailController.playerInit(autoplay: autoplay);
|
videoDetailController.playerInit(autoplay: autoplay);
|
||||||
@ -280,19 +281,13 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
final double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
|
final double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
|
||||||
final double pinnedHeaderHeight =
|
final double pinnedHeaderHeight =
|
||||||
statusBarHeight + kToolbarHeight + videoHeight;
|
statusBarHeight + kToolbarHeight + videoHeight;
|
||||||
if (MediaQuery.of(context).orientation == Orientation.landscape ||
|
|
||||||
plPlayerController?.isFullScreen.value == true) {
|
|
||||||
enterFullScreen();
|
|
||||||
} else {
|
|
||||||
exitFullScreen();
|
|
||||||
}
|
|
||||||
Widget childWhenDisabled = SafeArea(
|
Widget childWhenDisabled = SafeArea(
|
||||||
top: MediaQuery.of(context).orientation == Orientation.portrait &&
|
top: MediaQuery.of(context).orientation == Orientation.portrait &&
|
||||||
plPlayerController?.isFullScreen.value == true,
|
plPlayerController?.isFullScreen.value == true,
|
||||||
bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
|
bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
|
||||||
plPlayerController?.isFullScreen.value == true,
|
plPlayerController?.isFullScreen.value == true,
|
||||||
left: plPlayerController?.isFullScreen.value != true,
|
left: false, //plPlayerController?.isFullScreen.value != true,
|
||||||
right: plPlayerController?.isFullScreen.value != true,
|
right: false, //plPlayerController?.isFullScreen.value != true,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@ -309,10 +304,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
body: ExtendedNestedScrollView(
|
body: ExtendedNestedScrollView(
|
||||||
controller: _extendNestCtr,
|
controller: _extendNestCtr,
|
||||||
headerSliverBuilder:
|
headerSliverBuilder:
|
||||||
(BuildContext context, bool innerBoxIsScrolled) {
|
(BuildContext context2, bool innerBoxIsScrolled) {
|
||||||
return <Widget>[
|
return <Widget>[
|
||||||
Obx(
|
Obx(
|
||||||
() => SliverAppBar(
|
() {
|
||||||
|
if (MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.landscape ||
|
||||||
|
plPlayerController?.isFullScreen.value == true) {
|
||||||
|
enterFullScreen();
|
||||||
|
} else {
|
||||||
|
exitFullScreen();
|
||||||
|
}
|
||||||
|
return SliverAppBar(
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
// 假装使用一个非空变量,避免Obx检测不到而罢工
|
// 假装使用一个非空变量,避免Obx检测不到而罢工
|
||||||
pinned: videoDetailController.autoPlay.value ^
|
pinned: videoDetailController.autoPlay.value ^
|
||||||
@ -333,8 +336,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
background: PopScope(
|
background: PopScope(
|
||||||
canPop:
|
canPop: plPlayerController?.isFullScreen.value !=
|
||||||
plPlayerController?.isFullScreen.value != true,
|
true,
|
||||||
onPopInvoked: (bool didPop) {
|
onPopInvoked: (bool didPop) {
|
||||||
if (plPlayerController?.isFullScreen.value ==
|
if (plPlayerController?.isFullScreen.value ==
|
||||||
true) {
|
true) {
|
||||||
@ -349,11 +352,13 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
BoxConstraints boxConstraints) {
|
BoxConstraints boxConstraints) {
|
||||||
final double maxWidth = boxConstraints.maxWidth;
|
final double maxWidth =
|
||||||
|
boxConstraints.maxWidth;
|
||||||
final double maxHeight =
|
final double maxHeight =
|
||||||
boxConstraints.maxHeight;
|
boxConstraints.maxHeight;
|
||||||
return Stack(
|
return Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
if (isShowing)
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
@ -361,9 +366,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
if (snapshot.hasData &&
|
if (snapshot.hasData &&
|
||||||
snapshot.data['status']) {
|
snapshot.data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => !videoDetailController
|
() =>
|
||||||
|
!videoDetailController
|
||||||
.autoPlay.value
|
.autoPlay.value
|
||||||
? const SizedBox()
|
? nil
|
||||||
: PLVideoPlayer(
|
: PLVideoPlayer(
|
||||||
controller:
|
controller:
|
||||||
plPlayerController!,
|
plPlayerController!,
|
||||||
@ -372,13 +378,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
.headerControl,
|
.headerControl,
|
||||||
danmuWidget: Obx(
|
danmuWidget: Obx(
|
||||||
() => PlDanmaku(
|
() => PlDanmaku(
|
||||||
key: Key(
|
key: Key(videoDetailController
|
||||||
videoDetailController
|
|
||||||
.danmakuCid
|
.danmakuCid
|
||||||
.value
|
.value
|
||||||
.toString()),
|
.toString()),
|
||||||
cid:
|
cid: videoDetailController
|
||||||
videoDetailController
|
|
||||||
.danmakuCid
|
.danmakuCid
|
||||||
.value,
|
.value,
|
||||||
playerController:
|
playerController:
|
||||||
@ -445,40 +449,32 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var res = await UserHttp
|
var res = await UserHttp
|
||||||
.toViewLater(
|
.toViewLater(
|
||||||
bvid:
|
bvid: videoDetailController
|
||||||
videoDetailController
|
|
||||||
.bvid);
|
.bvid);
|
||||||
SmartDialog.showToast(
|
SmartDialog
|
||||||
|
.showToast(
|
||||||
res['msg']);
|
res['msg']);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons
|
icon: const Icon(Icons
|
||||||
.history_outlined),
|
.history_outlined),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 14)
|
const SizedBox(
|
||||||
|
width: 14)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 12,
|
right: 12,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
child: TextButton.icon(
|
child: IconButton(
|
||||||
style: ButtonStyle(
|
tooltip: '播放',
|
||||||
backgroundColor:
|
|
||||||
MaterialStateProperty
|
|
||||||
.resolveWith(
|
|
||||||
(states) {
|
|
||||||
return Colors.white
|
|
||||||
.withOpacity(0.8);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
handlePlay(),
|
handlePlay(),
|
||||||
icon: const Icon(
|
icon: Image.asset(
|
||||||
Icons.play_circle_outline,
|
'assets/images/play.png',
|
||||||
size: 20,
|
width: 60,
|
||||||
),
|
height: 60,
|
||||||
label: const Text('轻触封面播放'),
|
)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
@ -489,7 +485,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
@ -500,7 +497,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// },
|
// },
|
||||||
/// 不收回
|
/// 不收回
|
||||||
pinnedHeaderSliverHeightBuilder: () {
|
pinnedHeaderSliverHeightBuilder: () {
|
||||||
return plPlayerController?.isFullScreen.value == true
|
return MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.landscape ||
|
||||||
|
plPlayerController?.isFullScreen.value == true
|
||||||
? MediaQuery.sizeOf(context).height
|
? MediaQuery.sizeOf(context).height
|
||||||
: pinnedHeaderHeight;
|
: pinnedHeaderHeight;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user