opt: vertical video layout
This commit is contained in:
@ -125,6 +125,8 @@ class VideoDetailController extends GetxController
|
||||
RxInt watchLaterCount = 0.obs;
|
||||
List<SegmentDataModel> skipSegments = <SegmentDataModel>[];
|
||||
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,
|
||||
|
@ -221,9 +221,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// _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<VideoDetailPage>
|
||||
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;
|
||||
|
Reference in New Issue
Block a user