fix:播放切换问题修复
This commit is contained in:
parent
5fc3edfbe4
commit
9c223bd2d1
@ -21,6 +21,7 @@ class KtExploreLogic extends GetxController {
|
|||||||
final PageController pageController = PageController(viewportFraction: .95);
|
final PageController pageController = PageController(viewportFraction: .95);
|
||||||
final int preloadRange = 1;
|
final int preloadRange = 1;
|
||||||
bool isRefresh = false;
|
bool isRefresh = false;
|
||||||
|
final mainLogic = Get.find<KtMainLogic>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
@ -123,10 +124,10 @@ class KtExploreLogic extends GetxController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (state.controllers[index] != null) {
|
if (state.controllers[index] != null) {
|
||||||
state.controllers[index]?.play();
|
if (mainLogic.curIndex == 1) state.controllers[index]?.play();
|
||||||
} else {
|
} else {
|
||||||
if (!isToggle) await _initializeController(index);
|
if (!isToggle) await _initializeController(index);
|
||||||
state.controllers[index]?.play();
|
if (mainLogic.curIndex == 1) state.controllers[index]?.play();
|
||||||
}
|
}
|
||||||
// 预加载新的相邻视频,并释放多余控制器
|
// 预加载新的相邻视频,并释放多余控制器
|
||||||
_preloadAdjacentVideos();
|
_preloadAdjacentVideos();
|
||||||
@ -165,13 +166,16 @@ class KtExploreLogic extends GetxController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await controller.initialize();
|
await controller.initialize();
|
||||||
final mainLogic = Get.find<KtMainLogic>();
|
|
||||||
if (index == state.currentPage && mainLogic.curIndex == 1) {
|
if (index == state.currentPage && mainLogic.curIndex == 1) {
|
||||||
controller.play();
|
controller.play();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
controller.addListener(() {
|
controller.addListener(() {
|
||||||
if (state.currentPage == index && mainLogic.curIndex == 1) update();
|
if (state.currentPage == index && mainLogic.curIndex == 1) {
|
||||||
|
update();
|
||||||
|
} else {
|
||||||
|
controller.pause();
|
||||||
|
}
|
||||||
|
|
||||||
if (controller.value.isCompleted && !controller.value.isBuffering) {
|
if (controller.value.isCompleted && !controller.value.isBuffering) {
|
||||||
onPageChanged(index + 1, isToggle: true);
|
onPageChanged(index + 1, isToggle: true);
|
||||||
|
@ -174,6 +174,20 @@ class _KtExplorePageState extends State<KtExplorePage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (videoPlayerController.value.isInitialized)
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
videoPlayerController.value.isPlaying
|
||||||
|
? videoPlayerController.pause()
|
||||||
|
: videoPlayerController.play();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: ScreenUtil().screenWidth,
|
||||||
|
height: ScreenUtil().screenHeight,
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@ -263,6 +277,7 @@ class _KtExplorePageState extends State<KtExplorePage>
|
|||||||
child: Image.asset('ic_play.png'.ktIcon, width: 62.w),
|
child: Image.asset('ic_play.png'.ktIcon, width: 62.w),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -96,7 +96,7 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Get Hooked in Seconds',
|
'Get Hooked in Seconds',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12.sp,
|
fontSize: 11.sp,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -166,7 +166,7 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(width: 17.w),
|
SizedBox(width: 15.w),
|
||||||
Column(
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -184,7 +184,7 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Image.asset('ic_star.png'.ktIcon, width: 14.w),
|
Image.asset('ic_star.png'.ktIcon, width: 14.w),
|
||||||
SizedBox(width: 4.w),
|
SizedBox(width: 3.w),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 162.w,
|
width: 162.w,
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -257,7 +257,7 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
SizedBox(width: 4.w),
|
SizedBox(width: 4.w),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 9.w),
|
SizedBox(height: 8.w),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 117.w,
|
height: 117.w,
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
@ -555,8 +555,13 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
width: ((ScreenUtil().screenWidth - 42.w) / 3) - 4.w,
|
||||||
child: Text(
|
child: Text(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
item.categoryName ?? '',
|
item.categoryName ?? '',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14.sp,
|
fontSize: 14.sp,
|
||||||
color: Color(0xFF1E1E20),
|
color: Color(0xFF1E1E20),
|
||||||
@ -566,6 +571,7 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (_, __) => SizedBox(width: 6.w),
|
separatorBuilder: (_, __) => SizedBox(width: 6.w),
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
@ -9,6 +10,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
import 'package:visibility_detector/visibility_detector.dart';
|
import 'package:visibility_detector/visibility_detector.dart';
|
||||||
|
|
||||||
|
import '../../kt_model/kt_video_detail_bean.dart';
|
||||||
import '../../kt_utils/kt_toast_utils.dart';
|
import '../../kt_utils/kt_toast_utils.dart';
|
||||||
import '../../kt_widgets/kt_network_image.dart';
|
import '../../kt_widgets/kt_network_image.dart';
|
||||||
import '../../kt_widgets/kt_status_widget.dart';
|
import '../../kt_widgets/kt_status_widget.dart';
|
||||||
@ -201,7 +203,20 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
if (!isAllOver) Center(child: CircularProgressIndicator()),
|
if (!isAllOver) Center(child: CircularProgressIndicator()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (episode.isLock == true) return;
|
||||||
|
(controller?.value.isPlaying ?? true)
|
||||||
|
? controller?.pause()
|
||||||
|
: controller?.play();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: ScreenUtil().screenWidth,
|
||||||
|
height: ScreenUtil().screenHeight,
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
if (episode.isLock == true)
|
if (episode.isLock == true)
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -261,7 +276,6 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Image.asset('ic_coin.png'.ktIcon, width: 18.7.w),
|
Image.asset('ic_coin.png'.ktIcon, width: 18.7.w),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -277,7 +291,6 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Image.asset('ic_coin.png'.ktIcon, width: 11.2.w),
|
Image.asset('ic_coin.png'.ktIcon, width: 11.2.w),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user