Compare commits
No commits in common. "dev" and "main" have entirely different histories.
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 274 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 91 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 617 B |
@ -359,7 +359,6 @@ class VideoInfo {
|
|||||||
num? isVip,
|
num? isVip,
|
||||||
Revolution? revolution,
|
Revolution? revolution,
|
||||||
String? imageUrl,
|
String? imageUrl,
|
||||||
String? playSeconds,
|
|
||||||
}) {
|
}) {
|
||||||
_id = id;
|
_id = id;
|
||||||
_shortPlayVideoId = shortPlayVideoId;
|
_shortPlayVideoId = shortPlayVideoId;
|
||||||
@ -373,7 +372,6 @@ class VideoInfo {
|
|||||||
_isVip = isVip;
|
_isVip = isVip;
|
||||||
_revolution = revolution;
|
_revolution = revolution;
|
||||||
_imageUrl = imageUrl;
|
_imageUrl = imageUrl;
|
||||||
_playSeconds = playSeconds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoInfo.fromJson(dynamic json) {
|
VideoInfo.fromJson(dynamic json) {
|
||||||
@ -391,7 +389,6 @@ class VideoInfo {
|
|||||||
? Revolution.fromJson(json['revolution'])
|
? Revolution.fromJson(json['revolution'])
|
||||||
: null;
|
: null;
|
||||||
_imageUrl = json['image_url'];
|
_imageUrl = json['image_url'];
|
||||||
_playSeconds = json['play_seconds'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
num? _id;
|
num? _id;
|
||||||
@ -406,7 +403,7 @@ class VideoInfo {
|
|||||||
num? _isVip;
|
num? _isVip;
|
||||||
Revolution? _revolution;
|
Revolution? _revolution;
|
||||||
String? _imageUrl;
|
String? _imageUrl;
|
||||||
String? _playSeconds;
|
|
||||||
VideoInfo copyWith({
|
VideoInfo copyWith({
|
||||||
num? id,
|
num? id,
|
||||||
num? shortPlayVideoId,
|
num? shortPlayVideoId,
|
||||||
@ -420,7 +417,6 @@ class VideoInfo {
|
|||||||
num? isVip,
|
num? isVip,
|
||||||
Revolution? revolution,
|
Revolution? revolution,
|
||||||
String? imageUrl,
|
String? imageUrl,
|
||||||
String? playSeconds,
|
|
||||||
}) => VideoInfo(
|
}) => VideoInfo(
|
||||||
id: id ?? _id,
|
id: id ?? _id,
|
||||||
shortPlayVideoId: shortPlayVideoId ?? _shortPlayVideoId,
|
shortPlayVideoId: shortPlayVideoId ?? _shortPlayVideoId,
|
||||||
@ -434,7 +430,6 @@ class VideoInfo {
|
|||||||
isVip: isVip ?? _isVip,
|
isVip: isVip ?? _isVip,
|
||||||
revolution: revolution ?? _revolution,
|
revolution: revolution ?? _revolution,
|
||||||
imageUrl: imageUrl ?? _imageUrl,
|
imageUrl: imageUrl ?? _imageUrl,
|
||||||
playSeconds: playSeconds ?? _playSeconds,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
num? get id => _id;
|
num? get id => _id;
|
||||||
@ -461,8 +456,6 @@ class VideoInfo {
|
|||||||
|
|
||||||
String? get imageUrl => _imageUrl;
|
String? get imageUrl => _imageUrl;
|
||||||
|
|
||||||
String? get playSeconds => _playSeconds;
|
|
||||||
|
|
||||||
set id(num? value) => _id = value;
|
set id(num? value) => _id = value;
|
||||||
|
|
||||||
set shortPlayVideoId(num? value) => _shortPlayVideoId = value;
|
set shortPlayVideoId(num? value) => _shortPlayVideoId = value;
|
||||||
@ -487,8 +480,6 @@ class VideoInfo {
|
|||||||
|
|
||||||
set imageUrl(String? value) => _imageUrl = value;
|
set imageUrl(String? value) => _imageUrl = value;
|
||||||
|
|
||||||
set playSeconds(String? value) => _playSeconds = value;
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final map = <String, dynamic>{};
|
final map = <String, dynamic>{};
|
||||||
map['id'] = _id;
|
map['id'] = _id;
|
||||||
@ -505,7 +496,6 @@ class VideoInfo {
|
|||||||
map['revolution'] = _revolution?.toJson();
|
map['revolution'] = _revolution?.toJson();
|
||||||
}
|
}
|
||||||
map['image_url'] = _imageUrl;
|
map['image_url'] = _imageUrl;
|
||||||
map['play_seconds'] = _playSeconds;
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,87 +66,6 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 悬浮小视频卡片
|
|
||||||
if (state.showVideo && state.curVideo != null)
|
|
||||||
Positioned(
|
|
||||||
bottom: 2.w,
|
|
||||||
right: 15.w,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => Get.toNamed(
|
|
||||||
KtRoutes.shortVideo,
|
|
||||||
arguments: {
|
|
||||||
'shortPlayId': state.curVideo?.shortPlayId,
|
|
||||||
'imageUrl': state.curVideo?.imageUrl ?? '',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
width: 345.w,
|
|
||||||
height: 40.w,
|
|
||||||
padding: EdgeInsets.only(right: 10.w),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(20.w),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 40.w,
|
|
||||||
height: 40.w,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
image: DecorationImage(
|
|
||||||
image: AssetImage('home_bottom_video.png'.ktIcon),
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: KtNetworkImage(
|
|
||||||
imageUrl: state.curVideo?.imageUrl ?? '',
|
|
||||||
width: 30.w,
|
|
||||||
height: 30.w,
|
|
||||||
borderRadius: BorderRadius.circular(15.w),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 8.w),
|
|
||||||
Container(
|
|
||||||
constraints: BoxConstraints(maxWidth: 160.w),
|
|
||||||
child: Text(
|
|
||||||
state.curVideo?.name ?? '',
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14.sp,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF1E1E20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 20.w),
|
|
||||||
Text(
|
|
||||||
'Ep.${state.curVideo?.process}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12.sp,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF94949B),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Image.asset(
|
|
||||||
'ic_home_play.png'.ktIcon,
|
|
||||||
width: 24.w,
|
|
||||||
height: 24.w,
|
|
||||||
),
|
|
||||||
SizedBox(width: 14.w),
|
|
||||||
Image.asset(
|
|
||||||
'ic_home_eposide.png'.ktIcon,
|
|
||||||
width: 24.w,
|
|
||||||
height: 24.w,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -1179,7 +1098,8 @@ class _KtHomePageState extends State<KtHomePage>
|
|||||||
height: 127.w,
|
height: 127.w,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
video.name ?? '',
|
video.name ?? '',
|
||||||
|
|||||||
@ -95,7 +95,6 @@ class _KtMainPageState extends State<KtMainPage>
|
|||||||
itemCount: _tabsTitle.length,
|
itemCount: _tabsTitle.length,
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
backgroundColor: Colors.white,
|
|
||||||
selectedItemColor: Color(0xFF1E1E20),
|
selectedItemColor: Color(0xFF1E1E20),
|
||||||
selectedLabelStyle: TextStyle(
|
selectedLabelStyle: TextStyle(
|
||||||
fontSize: 10.sp,
|
fontSize: 10.sp,
|
||||||
@ -103,7 +102,7 @@ class _KtMainPageState extends State<KtMainPage>
|
|||||||
),
|
),
|
||||||
unselectedLabelStyle: TextStyle(
|
unselectedLabelStyle: TextStyle(
|
||||||
fontSize: 10.sp,
|
fontSize: 10.sp,
|
||||||
color: Color(0xFF94949B),
|
color: Color(0xFF95959C),
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
type: BottomNavigationBarType.fixed,
|
type: BottomNavigationBarType.fixed,
|
||||||
|
|||||||
@ -38,8 +38,8 @@ class MyListLogic extends GetxController {
|
|||||||
state.loadStatus = KtLoadStatusType.loading;
|
state.loadStatus = KtLoadStatusType.loading;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
state.curFavoriteIndex = 1;
|
state.curFavoriteIndex = 1;
|
||||||
// state.favoriteList.clear();
|
state.favoriteList.clear();
|
||||||
// state.chestList.clear();
|
state.chestList.clear();
|
||||||
}
|
}
|
||||||
if (loadMore) {
|
if (loadMore) {
|
||||||
state.curFavoriteIndex++;
|
state.curFavoriteIndex++;
|
||||||
@ -64,10 +64,6 @@ class MyListLogic extends GetxController {
|
|||||||
refreshCtrl.loadNoData();
|
refreshCtrl.loadNoData();
|
||||||
chestRefreshCtrl.loadNoData();
|
chestRefreshCtrl.loadNoData();
|
||||||
}
|
}
|
||||||
if (refresh) {
|
|
||||||
state.favoriteList.clear();
|
|
||||||
state.chestList.clear();
|
|
||||||
}
|
|
||||||
state.favoriteList.addAll(list);
|
state.favoriteList.addAll(list);
|
||||||
if (state.favoriteList.length > 3) {
|
if (state.favoriteList.length > 3) {
|
||||||
state.chestList = state.favoriteList.sublist(0, 3);
|
state.chestList = state.favoriteList.sublist(0, 3);
|
||||||
@ -90,7 +86,7 @@ class MyListLogic extends GetxController {
|
|||||||
getHistoryList({bool refresh = false, bool loadMore = false}) async {
|
getHistoryList({bool refresh = false, bool loadMore = false}) async {
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
state.curHistoryIndex = 1;
|
state.curHistoryIndex = 1;
|
||||||
// state.historyList.clear();
|
state.historyList.clear();
|
||||||
}
|
}
|
||||||
if (loadMore) {
|
if (loadMore) {
|
||||||
state.curHistoryIndex++;
|
state.curHistoryIndex++;
|
||||||
@ -111,9 +107,7 @@ class MyListLogic extends GetxController {
|
|||||||
...res.data['list'].map((item) => KtHistoryVideoBean.fromJson(item)),
|
...res.data['list'].map((item) => KtHistoryVideoBean.fromJson(item)),
|
||||||
];
|
];
|
||||||
if (list.length < 20) refreshCtrl.loadNoData();
|
if (list.length < 20) refreshCtrl.loadNoData();
|
||||||
if (refresh) {
|
|
||||||
state.historyList.clear();
|
|
||||||
}
|
|
||||||
state.historyList.addAll(list);
|
state.historyList.addAll(list);
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class _KtMyListPageState extends State<KtMyListPage> {
|
|||||||
if (state.chestList.isNotEmpty)
|
if (state.chestList.isNotEmpty)
|
||||||
Container(
|
Container(
|
||||||
width: ScreenUtil().screenWidth - 30.w,
|
width: ScreenUtil().screenWidth - 30.w,
|
||||||
padding: EdgeInsets.fromLTRB(6.w, 46.w, 6.w, 6.w),
|
padding: EdgeInsets.fromLTRB(6.w, 53.w, 6.w, 6.w),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: AssetImage('collect_bg.png'.ktIcon),
|
image: AssetImage('collect_bg.png'.ktIcon),
|
||||||
@ -77,8 +77,6 @@ class _KtMyListPageState extends State<KtMyListPage> {
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => Get.to(KtMyChestPage()),
|
onTap: () => Get.to(KtMyChestPage()),
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(8.w),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
@ -92,13 +90,13 @@ class _KtMyListPageState extends State<KtMyListPage> {
|
|||||||
'ic_right_white.png'.ktIcon,
|
'ic_right_white.png'.ktIcon,
|
||||||
width: 10.w,
|
width: 10.w,
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 6.w),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 8.w),
|
SizedBox(height: 15.w),
|
||||||
Container(
|
Container(
|
||||||
height: 145.w,
|
height: 145.w,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@ -1,15 +1,12 @@
|
|||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:async';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:card_swiper/card_swiper.dart';
|
|
||||||
import 'package:flutter_kinetra/kt_pages/kt_mine/logic.dart';
|
import 'package:flutter_kinetra/kt_pages/kt_mine/logic.dart';
|
||||||
import 'package:flutter_kinetra/kt_pages/kt_short_video/state.dart';
|
import 'package:flutter_kinetra/kt_pages/kt_short_video/state.dart';
|
||||||
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
|
import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
|
||||||
import 'package:flutter_kinetra/kt_utils/kt_toast_utils.dart';
|
import 'package:flutter_kinetra/kt_utils/kt_toast_utils.dart';
|
||||||
import 'package:flutter_kinetra/kt_pages/kt_home/logic.dart';
|
|
||||||
import 'package:flutter_kinetra/kt_pages/kt_my_list/logic.dart';
|
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
@ -17,13 +14,10 @@ import 'package:video_player/video_player.dart';
|
|||||||
import '../../dio_cilent/kt_apis.dart';
|
import '../../dio_cilent/kt_apis.dart';
|
||||||
import '../../dio_cilent/kt_request.dart';
|
import '../../dio_cilent/kt_request.dart';
|
||||||
import '../../kt_model/kt_video_detail_bean.dart';
|
import '../../kt_model/kt_video_detail_bean.dart';
|
||||||
import '../../kt_model/kt_short_video_bean.dart';
|
|
||||||
import '../../kt_utils/kt_device_info_utils.dart';
|
import '../../kt_utils/kt_device_info_utils.dart';
|
||||||
import '../../kt_widgets/kt_status_widget.dart';
|
import '../../kt_widgets/kt_status_widget.dart';
|
||||||
import '../../kt_widgets/kt_store_widget.dart';
|
import '../../kt_widgets/kt_store_widget.dart';
|
||||||
import '../../kt_widgets/kt_dialog.dart';
|
|
||||||
import '../kt_mine/kt_store/logic.dart';
|
import '../kt_mine/kt_store/logic.dart';
|
||||||
import '../../kt_widgets/kt_network_image.dart';
|
|
||||||
|
|
||||||
class VideoPlayLogic extends GetxController {
|
class VideoPlayLogic extends GetxController {
|
||||||
final state = VideoPlayState();
|
final state = VideoPlayState();
|
||||||
@ -36,9 +30,6 @@ class VideoPlayLogic extends GetxController {
|
|||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
final userLogic = Get.put(KtMineLogic());
|
final userLogic = Get.put(KtMineLogic());
|
||||||
|
|
||||||
final mylistLogic = Get.put(MyListLogic());
|
|
||||||
final mylistState = Get.find<MyListLogic>().state;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@ -54,44 +45,16 @@ class VideoPlayLogic extends GetxController {
|
|||||||
state.imageUrl = Get.arguments['imageUrl'] ?? '';
|
state.imageUrl = Get.arguments['imageUrl'] ?? '';
|
||||||
state.activityId = Get.arguments['activityId'];
|
state.activityId = Get.arguments['activityId'];
|
||||||
state.isFromDiscover = Get.arguments['isFromDiscover'] ?? false;
|
state.isFromDiscover = Get.arguments['isFromDiscover'] ?? false;
|
||||||
startTimer();
|
|
||||||
fetchData();
|
fetchData();
|
||||||
getRecommend();
|
|
||||||
startVideoTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
clearCacheCtrl();
|
clearCacheCtrl();
|
||||||
state.timer?.cancel();
|
|
||||||
state.videotimer?.cancel();
|
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 推荐点击
|
|
||||||
initData(shortPlayId, imageUrl) {
|
|
||||||
uploadHistorySeconds(
|
|
||||||
controllers[currentIndex]?.value.position.inMilliseconds ?? 0,
|
|
||||||
);
|
|
||||||
Get.back();
|
|
||||||
state.shortPlayId = shortPlayId;
|
|
||||||
state.videoId = 0;
|
|
||||||
state.imageUrl = imageUrl;
|
|
||||||
state.isRecommend = false;
|
|
||||||
|
|
||||||
// pageController.dispose();
|
|
||||||
currentIndex = 0;
|
|
||||||
pageController.jumpToPage(currentIndex);
|
|
||||||
// pageController = PageController(initialPage: currentIndex);
|
|
||||||
clearCacheCtrl();
|
|
||||||
fetchData();
|
|
||||||
state.recommendList.clear();
|
|
||||||
getRecommend();
|
|
||||||
startTimer();
|
|
||||||
startVideoTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCacheCtrl() {
|
clearCacheCtrl() {
|
||||||
for (var controller in controllers) {
|
for (var controller in controllers) {
|
||||||
controller?.pause();
|
controller?.pause();
|
||||||
@ -125,8 +88,6 @@ class VideoPlayLogic extends GetxController {
|
|||||||
state.videoId = state.video?.videoInfo?.shortPlayVideoId ?? 0;
|
state.videoId = state.video?.videoInfo?.shortPlayVideoId ?? 0;
|
||||||
}
|
}
|
||||||
state.episodeList = state.video?.episodeList ?? [];
|
state.episodeList = state.video?.episodeList ?? [];
|
||||||
state.videoFirstTime =
|
|
||||||
int.tryParse(state.video?.videoInfo?.playSeconds ?? '0') ?? 0;
|
|
||||||
if (toPage) currentIndex = (state.video?.videoInfo?.episode ?? 1) - 1;
|
if (toPage) currentIndex = (state.video?.videoInfo?.episode ?? 1) - 1;
|
||||||
for (var video in state.episodeList) {
|
for (var video in state.episodeList) {
|
||||||
if (video.isLock == true) {
|
if (video.isLock == true) {
|
||||||
@ -144,7 +105,6 @@ class VideoPlayLogic extends GetxController {
|
|||||||
currentIndex,
|
currentIndex,
|
||||||
isToggle: true,
|
isToggle: true,
|
||||||
isUploadHistorySeconds: false,
|
isUploadHistorySeconds: false,
|
||||||
type: 1,
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
_initializeController(currentIndex);
|
_initializeController(currentIndex);
|
||||||
@ -163,37 +123,6 @@ class VideoPlayLogic extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5s之后返回推荐
|
|
||||||
void startTimer() {
|
|
||||||
state.timer = Timer(const Duration(seconds: 5), () {
|
|
||||||
state.isRecommend = true;
|
|
||||||
update();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5s 之后隐藏控制器
|
|
||||||
void startVideoTimer() {
|
|
||||||
state.videotimer?.cancel();
|
|
||||||
state.videotimer = Timer(const Duration(seconds: 5), () {
|
|
||||||
state.isVideoctrHide = true;
|
|
||||||
update();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取推荐列表
|
|
||||||
getRecommend() async {
|
|
||||||
ApiResponse res = await KtHttpClient().request(
|
|
||||||
KtApis.getDetailsRecommand,
|
|
||||||
method: HttpMethod.get,
|
|
||||||
);
|
|
||||||
if (res.success) {
|
|
||||||
state.recommendList = [
|
|
||||||
...res.data['list'].map((item) => KtShortVideoBean.fromJson(item)),
|
|
||||||
];
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void reportHistory() {
|
void reportHistory() {
|
||||||
if (currentIndex < 0 || currentIndex >= state.episodeList.length) return;
|
if (currentIndex < 0 || currentIndex >= state.episodeList.length) return;
|
||||||
Map<String, dynamic> params = {
|
Map<String, dynamic> params = {
|
||||||
@ -212,19 +141,6 @@ class VideoPlayLogic extends GetxController {
|
|||||||
KtHttpClient().request(KtApis.activeAfterWatchingVideo, data: params);
|
KtHttpClient().request(KtApis.activeAfterWatchingVideo, data: params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateHomeVideo() {
|
|
||||||
final homeLogic = Get.put(KtHomeLogic());
|
|
||||||
final homeState = Get.find<KtHomeLogic>().state;
|
|
||||||
int playTime = controllers[currentIndex]?.value.position.inSeconds ?? 0;
|
|
||||||
homeState.curVideo = KtShortVideoBean()
|
|
||||||
..shortPlayId = state.shortPlayId
|
|
||||||
..imageUrl = state.video?.shortPlayInfo?.imageUrl
|
|
||||||
..name = state.video?.shortPlayInfo?.name
|
|
||||||
..playTime = playTime
|
|
||||||
..process = currentIndex + 1;
|
|
||||||
homeLogic.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 切换剧集时处理视频状态
|
// 切换剧集时处理视频状态
|
||||||
Future<void> onPageChanged(
|
Future<void> onPageChanged(
|
||||||
int index, {
|
int index, {
|
||||||
@ -261,9 +177,6 @@ class VideoPlayLogic extends GetxController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
currentIndex = index;
|
currentIndex = index;
|
||||||
if (type == 1) {
|
|
||||||
controllers[index]?.seekTo(Duration(milliseconds: state.videoFirstTime));
|
|
||||||
}
|
|
||||||
if (state.episodeList[index].isLock == true) {
|
if (state.episodeList[index].isLock == true) {
|
||||||
controllers[index]?.seekTo(Duration(seconds: 0));
|
controllers[index]?.seekTo(Duration(seconds: 0));
|
||||||
controllers[index]?.pause();
|
controllers[index]?.pause();
|
||||||
@ -286,9 +199,8 @@ class VideoPlayLogic extends GetxController {
|
|||||||
controllers[index]?.play();
|
controllers[index]?.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controllers[index]?.setPlaybackSpeed(state.currentSpeed);
|
controllers[index]?.setPlaybackSpeed(state.currentSpeed);
|
||||||
updateHomeVideo();
|
// updateHomeVideo();
|
||||||
// print('----curIndex:$currentIndex');
|
// print('----curIndex:$currentIndex');
|
||||||
// 预加载新的相邻视频,并释放多余控制器
|
// 预加载新的相邻视频,并释放多余控制器
|
||||||
_preloadAdjacentVideos();
|
_preloadAdjacentVideos();
|
||||||
@ -329,8 +241,7 @@ class VideoPlayLogic extends GetxController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await controller.initialize();
|
await controller.initialize();
|
||||||
if (index == currentIndex &&
|
if (index == currentIndex && (episode.isLock == false || userLogic.state.userInfo.isVip == true)) {
|
||||||
(episode.isLock == false || userLogic.state.userInfo.isVip == true)) {
|
|
||||||
controller.play();
|
controller.play();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -340,7 +251,7 @@ class VideoPlayLogic extends GetxController {
|
|||||||
if (currentIndex == index && !_disposed) update();
|
if (currentIndex == index && !_disposed) update();
|
||||||
if (currentIndex == state.episodeList.length - 1 &&
|
if (currentIndex == state.episodeList.length - 1 &&
|
||||||
(controllers.last?.value.isCompleted ?? false)) {
|
(controllers.last?.value.isCompleted ?? false)) {
|
||||||
showRecommendDialog();
|
// showRecommendDialog();
|
||||||
}
|
}
|
||||||
if (controller.value.isCompleted && !controller.value.isBuffering) {
|
if (controller.value.isCompleted && !controller.value.isBuffering) {
|
||||||
onPageChanged(index + 1, isToggle: true);
|
onPageChanged(index + 1, isToggle: true);
|
||||||
@ -380,21 +291,20 @@ class VideoPlayLogic extends GetxController {
|
|||||||
|
|
||||||
Future<void> likeVideo() async {
|
Future<void> likeVideo() async {
|
||||||
if (state.video == null) return;
|
if (state.video == null) return;
|
||||||
|
|
||||||
Map<String, dynamic> params = {
|
Map<String, dynamic> params = {
|
||||||
"short_play_id": state.video?.shortPlayInfo?.shortPlayId,
|
"short_play_id": state.video?.shortPlayInfo?.shortPlayId,
|
||||||
"video_id": state.episodeList[currentIndex].id,
|
"video_id": state.episodeList[currentIndex].id,
|
||||||
};
|
};
|
||||||
if (state.video?.shortPlayInfo?.isCollect ?? false) {
|
if (state.video?.shortPlayInfo?.isCollect ?? false) {
|
||||||
// await KtHttpClient().request(KtApis.deleteFavoriteVideo, data: params);
|
await KtHttpClient().request(KtApis.deleteFavoriteVideo, data: params);
|
||||||
cancelCollect(state.video!.shortPlayInfo!.shortPlayId!);
|
|
||||||
} else {
|
} else {
|
||||||
await KtHttpClient().request(KtApis.collectVideo, data: params);
|
await KtHttpClient().request(KtApis.collectVideo, data: params);
|
||||||
|
}
|
||||||
|
|
||||||
state.video?.shortPlayInfo?.isCollect =
|
state.video?.shortPlayInfo?.isCollect =
|
||||||
!(state.video?.shortPlayInfo?.isCollect ?? false);
|
!(state.video?.shortPlayInfo?.isCollect ?? false);
|
||||||
update();
|
update();
|
||||||
mylistLogic.getCollectList(refresh: true);
|
|
||||||
mylistLogic.getHistoryList(refresh: true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 购买剧集
|
// 购买剧集
|
||||||
@ -518,202 +428,4 @@ class VideoPlayLogic extends GetxController {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelCollect(num id) async {
|
|
||||||
Get.dialog(
|
|
||||||
KtDialog(
|
|
||||||
title: 'Remove from your list?',
|
|
||||||
subTitle: 'This drama will be removed from your saved list.',
|
|
||||||
rightBtnText: 'Remove',
|
|
||||||
rightBtnIcon: 'ic_dialog_delete.png',
|
|
||||||
rightBtnFunc: () async {
|
|
||||||
ApiResponse res = await KtHttpClient().request(
|
|
||||||
KtApis.deleteFavoriteVideo,
|
|
||||||
queryParameters: {'short_play_id': id},
|
|
||||||
);
|
|
||||||
if (res.success) {
|
|
||||||
state.video?.shortPlayInfo?.isCollect =
|
|
||||||
!(state.video?.shortPlayInfo?.isCollect ?? false);
|
|
||||||
update();
|
|
||||||
// state.favoriteList.removeWhere((item) => id == item.shortPlayId);
|
|
||||||
mylistState.chestList.removeWhere((item) => id == item.shortPlayId);
|
|
||||||
mylistState.historyList
|
|
||||||
.firstWhereOrNull((item) => id == item.shortPlayId)
|
|
||||||
?.isCollect =
|
|
||||||
0;
|
|
||||||
mylistLogic.update();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
showRecommendDialog() {
|
|
||||||
EasyThrottle.throttle('show-recommend', Duration(seconds: 3), () async {
|
|
||||||
controllers[currentIndex]?.pause();
|
|
||||||
Get.bottomSheet(
|
|
||||||
isScrollControlled: true,
|
|
||||||
isDismissible: false,
|
|
||||||
enableDrag: false,
|
|
||||||
Stack(
|
|
||||||
children: [
|
|
||||||
Positioned(
|
|
||||||
top: ScreenUtil().statusBarHeight + 10.w,
|
|
||||||
left: 16.w,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
EasyThrottle.throttle(
|
|
||||||
'back-recommend',
|
|
||||||
Duration(seconds: 3),
|
|
||||||
() async {
|
|
||||||
Get.back();
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Image.asset('ic_back_white.png'.ktIcon, width: 24.w),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
left: 0,
|
|
||||||
child: Container(
|
|
||||||
height: 503.w,
|
|
||||||
width: ScreenUtil().screenWidth,
|
|
||||||
padding: EdgeInsets.fromLTRB(0.w, 75.w, 0.w, 20.w),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
image: DecorationImage(
|
|
||||||
image: AssetImage('video_recommend_bg.png'.ktIcon),
|
|
||||||
fit: BoxFit.fill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
SizedBox(width: 15.w),
|
|
||||||
Image.asset('ip.png'.ktIcon, width: 38.w, height: 40.w),
|
|
||||||
SizedBox(width: 6.w),
|
|
||||||
Container(
|
|
||||||
height: 30.w,
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 14.w),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Color(0xFF1E1E20),
|
|
||||||
borderRadius: BorderRadius.circular(15.w),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
'More Drama Gold Below!',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Color(0xFFA7F62F),
|
|
||||||
fontSize: 16.sp,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 290.w,
|
|
||||||
child: Swiper(
|
|
||||||
layout: SwiperLayout.CUSTOM,
|
|
||||||
customLayoutOption:
|
|
||||||
CustomLayoutOption(startIndex: -1, stateCount: 3)
|
|
||||||
..addRotate([-20.0 / 180, 0.0, 20.0 / 180])
|
|
||||||
..addTranslate([
|
|
||||||
Offset(-220.w, 0),
|
|
||||||
Offset(0, 0),
|
|
||||||
Offset(220.w, 0),
|
|
||||||
]),
|
|
||||||
itemWidth: 190.w,
|
|
||||||
itemHeight: 226.w,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final item =
|
|
||||||
state.recommendList[index %
|
|
||||||
state.recommendList.length];
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
initData(
|
|
||||||
state.recommendList[index].shortPlayId ?? -1,
|
|
||||||
state.recommendList[index].imageUrl ?? '',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: KtNetworkImage(
|
|
||||||
imageUrl: item.imageUrl ?? '',
|
|
||||||
width: 190.w,
|
|
||||||
height: 226.w,
|
|
||||||
borderRadius: BorderRadius.circular(20.w),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: state.recommendList.length,
|
|
||||||
loop: true,
|
|
||||||
autoplay: true,
|
|
||||||
onIndexChanged: (index) => state.recommendIndex = index,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
initData(
|
|
||||||
state
|
|
||||||
.recommendList[state.recommendIndex]
|
|
||||||
.shortPlayId ??
|
|
||||||
-1,
|
|
||||||
state
|
|
||||||
.recommendList[state.recommendIndex]
|
|
||||||
.imageUrl ??
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
width: 280.w,
|
|
||||||
height: 64.w,
|
|
||||||
padding: EdgeInsets.only(bottom: 16.w),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
image: DecorationImage(
|
|
||||||
image: AssetImage(
|
|
||||||
'video_recommend_btn.png'.ktIcon,
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
height: 48.w,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
'video_recommend_play.png'.ktIcon,
|
|
||||||
width: 18.w,
|
|
||||||
height: 18.w,
|
|
||||||
),
|
|
||||||
SizedBox(width: 4.w),
|
|
||||||
Text(
|
|
||||||
'watch now',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontSize: 14.sp,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,10 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import '../../kt_model/kt_video_detail_bean.dart';
|
import '../../kt_model/kt_video_detail_bean.dart';
|
||||||
import '../../kt_widgets/kt_status_widget.dart';
|
import '../../kt_widgets/kt_status_widget.dart';
|
||||||
import '../../kt_model/kt_short_video_bean.dart';
|
|
||||||
|
|
||||||
class VideoPlayState {
|
class VideoPlayState {
|
||||||
String imageUrl = '';
|
String imageUrl = '';
|
||||||
num shortPlayId = -1;
|
int shortPlayId = -1;
|
||||||
num videoId = -1;
|
num videoId = -1;
|
||||||
int videoFirstTime = 0;
|
|
||||||
int curUnlock = 999;
|
int curUnlock = 999;
|
||||||
int? activityId;
|
int? activityId;
|
||||||
bool isFromDiscover = false;
|
bool isFromDiscover = false;
|
||||||
@ -19,12 +15,4 @@ class VideoPlayState {
|
|||||||
int currentVideoIndex = 0;
|
int currentVideoIndex = 0;
|
||||||
double currentSpeed = 1.0;
|
double currentSpeed = 1.0;
|
||||||
final List<double> speedList = [0.75, 1.0, 1.25, 1.5, 2.0, 3.0];
|
final List<double> speedList = [0.75, 1.0, 1.25, 1.5, 2.0, 3.0];
|
||||||
List<KtShortVideoBean> recommendList = [];
|
|
||||||
int recommendIndex = 0;
|
|
||||||
|
|
||||||
bool isRecommend = false;
|
|
||||||
Timer? timer;
|
|
||||||
|
|
||||||
bool isVideoctrHide = false;
|
|
||||||
Timer? videotimer;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,6 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
state.imageUrl = Get.arguments['imageUrl'] ?? '';
|
state.imageUrl = Get.arguments['imageUrl'] ?? '';
|
||||||
// state.isFromRecommend = Get.arguments['isFromRecommend'] ?? false;
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,16 +54,9 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: true,
|
canPop: true,
|
||||||
onPopInvokedWithResult: (didPop, result) async {
|
onPopInvokedWithResult: (didPop, result) async {
|
||||||
if (logic.controllers.isNotEmpty) {
|
// if (logic.controllers.isNotEmpty) {
|
||||||
logic.uploadHistorySeconds(
|
// logic.uploadHistorySeconds(logic.controllers[logic.currentIndex]?.value.position.inMilliseconds ?? 0);
|
||||||
logic
|
// }
|
||||||
.controllers[logic.currentIndex]
|
|
||||||
?.value
|
|
||||||
.position
|
|
||||||
.inMilliseconds ??
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (didPop) return;
|
if (didPop) return;
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@ -214,22 +206,9 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (episode.isLock == true) return;
|
if (episode.isLock == true) return;
|
||||||
|
(controller?.value.isPlaying ?? true)
|
||||||
if (controller?.value.isPlaying ?? true) {
|
? controller?.pause()
|
||||||
if (state.isVideoctrHide) {
|
: controller?.play();
|
||||||
state.isVideoctrHide = false;
|
|
||||||
logic.startVideoTimer();
|
|
||||||
} else {
|
|
||||||
controller?.pause();
|
|
||||||
state.videotimer?.cancel();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logic.startVideoTimer();
|
|
||||||
controller?.play();
|
|
||||||
}
|
|
||||||
// (controller?.value.isPlaying ?? true)
|
|
||||||
// ? controller?.pause()
|
|
||||||
// : controller?.play();
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -319,19 +298,17 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
if (!state.isVideoctrHide) ...[
|
|
||||||
// 顶部返回
|
// 顶部返回
|
||||||
Positioned(
|
Positioned(
|
||||||
top: ScreenUtil().statusBarHeight + 10.w,
|
top: ScreenUtil().statusBarHeight + 10.w,
|
||||||
left: 16.w,
|
left: 16.w,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!state.isRecommend || state.recommendList.isEmpty) {
|
// if (state.isFromRecommend || state.recommendList.isEmpty) {
|
||||||
Get.back();
|
Get.back();
|
||||||
} else {
|
// } else {
|
||||||
logic.showRecommendDialog();
|
// logic.showRecommendDialog();
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
child: Image.asset('ic_back_white.png'.ktIcon, width: 24.w),
|
child: Image.asset('ic_back_white.png'.ktIcon, width: 24.w),
|
||||||
),
|
),
|
||||||
@ -439,7 +416,6 @@ class _VideoPlayPageState extends State<VideoPlayPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user