diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index e09dd20f..0f66ad02 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -125,6 +125,8 @@ class VideoDetailController extends GetxController RxInt watchLaterCount = 0.obs; List skipSegments = []; int? lastPosition; + // 默认屏幕方向 + RxString videoDirection = 'horizontal'.obs; @override void onInit() { @@ -283,6 +285,10 @@ class VideoDetailController extends GetxController } else { ScreenBrightness().resetScreenBrightness(); } + videoDirection.value = (firstVideo.width != null && + firstVideo.height != null) + ? (firstVideo.width! > firstVideo.height! ? 'horizontal' : 'vertical') + : 'horizontal'; await plPlayerController.setDataSource( DataSource( videoSource: video ?? videoUrl, @@ -299,11 +305,7 @@ class VideoDetailController extends GetxController seekTo: seekToTime ?? defaultST, duration: duration ?? Duration(milliseconds: data.timeLength ?? 0), // 宽>高 水平 否则 垂直 - direction: firstVideo.width != null && firstVideo.height != null - ? ((firstVideo.width! - firstVideo.height!) > 0 - ? 'horizontal' - : 'vertical') - : null, + direction: videoDirection.value, bvid: bvid, cid: cid.value, enableHeart: enableHeart, diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 1585a6f3..91f942d5 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -221,9 +221,15 @@ class _VideoDetailPageState extends State // _extendNestCtr监听 void _extendNestCtrListener() { final double offset = _extendNestCtr.position.pixels; - vdCtr.sheetHeight.value = - Get.size.height - videoHeight - statusBarHeight + offset; - appbarStream.add(offset); + if (vdCtr.videoDirection.value == 'horizontal') { + vdCtr.sheetHeight.value = + Get.size.height - videoHeight - statusBarHeight + offset; + appbarStream.add(offset); + } else { + if (offset > (Get.size.width * 22 / 16 - videoHeight)) { + appbarStream.add(offset - (Get.size.width * 22 / 16 - videoHeight)); + } + } } @override @@ -501,6 +507,12 @@ class _VideoDetailPageState extends State final double pinnedHeaderHeight = statusBarHeight + kToolbarHeight + videoHeight.value; // ignore: no_leading_underscores_for_local_identifiers + vdCtr.videoDirection.listen((p0) { + if (p0 == 'vertical') { + defaultVideoHeight = sizeContext.width * 22 / 16; + videoHeight.value = sizeContext.width * 22 / 16; + } + }); // 竖屏 final bool isPortrait = _context.orientation == Orientation.portrait;