opt: vertical video layout
This commit is contained in:
@ -125,6 +125,8 @@ class VideoDetailController extends GetxController
|
|||||||
RxInt watchLaterCount = 0.obs;
|
RxInt watchLaterCount = 0.obs;
|
||||||
List<SegmentDataModel> skipSegments = <SegmentDataModel>[];
|
List<SegmentDataModel> skipSegments = <SegmentDataModel>[];
|
||||||
int? lastPosition;
|
int? lastPosition;
|
||||||
|
// 默认屏幕方向
|
||||||
|
RxString videoDirection = 'horizontal'.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -283,6 +285,10 @@ class VideoDetailController extends GetxController
|
|||||||
} else {
|
} else {
|
||||||
ScreenBrightness().resetScreenBrightness();
|
ScreenBrightness().resetScreenBrightness();
|
||||||
}
|
}
|
||||||
|
videoDirection.value = (firstVideo.width != null &&
|
||||||
|
firstVideo.height != null)
|
||||||
|
? (firstVideo.width! > firstVideo.height! ? 'horizontal' : 'vertical')
|
||||||
|
: 'horizontal';
|
||||||
await plPlayerController.setDataSource(
|
await plPlayerController.setDataSource(
|
||||||
DataSource(
|
DataSource(
|
||||||
videoSource: video ?? videoUrl,
|
videoSource: video ?? videoUrl,
|
||||||
@ -299,11 +305,7 @@ class VideoDetailController extends GetxController
|
|||||||
seekTo: seekToTime ?? defaultST,
|
seekTo: seekToTime ?? defaultST,
|
||||||
duration: duration ?? Duration(milliseconds: data.timeLength ?? 0),
|
duration: duration ?? Duration(milliseconds: data.timeLength ?? 0),
|
||||||
// 宽>高 水平 否则 垂直
|
// 宽>高 水平 否则 垂直
|
||||||
direction: firstVideo.width != null && firstVideo.height != null
|
direction: videoDirection.value,
|
||||||
? ((firstVideo.width! - firstVideo.height!) > 0
|
|
||||||
? 'horizontal'
|
|
||||||
: 'vertical')
|
|
||||||
: null,
|
|
||||||
bvid: bvid,
|
bvid: bvid,
|
||||||
cid: cid.value,
|
cid: cid.value,
|
||||||
enableHeart: enableHeart,
|
enableHeart: enableHeart,
|
||||||
|
@ -221,9 +221,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// _extendNestCtr监听
|
// _extendNestCtr监听
|
||||||
void _extendNestCtrListener() {
|
void _extendNestCtrListener() {
|
||||||
final double offset = _extendNestCtr.position.pixels;
|
final double offset = _extendNestCtr.position.pixels;
|
||||||
vdCtr.sheetHeight.value =
|
if (vdCtr.videoDirection.value == 'horizontal') {
|
||||||
Get.size.height - videoHeight - statusBarHeight + offset;
|
vdCtr.sheetHeight.value =
|
||||||
appbarStream.add(offset);
|
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
|
@override
|
||||||
@ -501,6 +507,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
final double pinnedHeaderHeight =
|
final double pinnedHeaderHeight =
|
||||||
statusBarHeight + kToolbarHeight + videoHeight.value;
|
statusBarHeight + kToolbarHeight + videoHeight.value;
|
||||||
// ignore: no_leading_underscores_for_local_identifiers
|
// 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;
|
final bool isPortrait = _context.orientation == Orientation.portrait;
|
||||||
|
Reference in New Issue
Block a user