fix: 图片提交4x,提示画质。iOS logo提交;
This commit is contained in:
1 parent
2f1ec27802
commit
9e10608245
85 files changed
+1027
-645
No files matched your search
@@ -1,19 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:skywood/global/client/play_client.dart';
|
||||
import 'package:skywood/main/lib_file.dart';
|
||||
import 'package:skywood/pages/home/players/widget/player_bottom_widget.dart';
|
||||
import 'package:skywood/pages/home/players/widget/sky_player_view.dart';
|
||||
import 'package:skywood/utils/models/drama/skywood_detail.dart';
|
||||
import 'package:skywood/utils/models/drama/skywood_drama.dart';
|
||||
import 'package:skywood/utils/models/drama/skywood_home.dart';
|
||||
import 'package:skywood/utils/models/drama/skywood_episode.dart';
|
||||
import 'package:skywood/utils/tools/app_toast.dart';
|
||||
import 'package:skywood/utils/tools/widgets/sky_app_bar.dart';
|
||||
import 'package:skywood/utils/tools/widgets/sky_common_widget.dart';
|
||||
|
||||
class DramaDetailPage extends StatefulWidget {
|
||||
const DramaDetailPage({super.key,
|
||||
required this.dramaBean,
|
||||
});
|
||||
const DramaDetailPage({super.key, required this.dramaBean});
|
||||
|
||||
final SkywoodDrama dramaBean;
|
||||
|
||||
@@ -24,36 +20,49 @@ class DramaDetailPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DramaDetailPageState extends State<DramaDetailPage> {
|
||||
|
||||
SkywoodDetail? _detailBean;
|
||||
SkywoodEpisode? _selectedEpisode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_getDetailDrama();
|
||||
_getDetailDrama(
|
||||
shortPlayId: widget.dramaBean.shortPlayId ?? 0,
|
||||
shortPlayVideoId: widget.dramaBean.shortPlayVideoId ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
void _getDetailDrama() {
|
||||
print('currentEpisode===${widget.dramaBean.currentEpisode}');
|
||||
void _getDetailDrama({
|
||||
required int shortPlayId,
|
||||
required int shortPlayVideoId,
|
||||
}) {
|
||||
AppToast.showLottieLoading();
|
||||
PlayClient.getVideoDetail(
|
||||
shortPlayId: widget.dramaBean.shortPlayId ?? 0,
|
||||
shortPlayVideoId: widget.dramaBean.shortPlayVideoId ?? 0
|
||||
shortPlayId: shortPlayId,
|
||||
shortPlayVideoId: shortPlayVideoId,
|
||||
).then((value) {
|
||||
AppToast.dismiss();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_detailBean = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _onSelectedEpisode(SkywoodEpisode episode) {
|
||||
setState(() {
|
||||
_selectedEpisode = episode;
|
||||
});
|
||||
_getDetailDrama(
|
||||
shortPlayId: episode.shortPlayId,
|
||||
shortPlayVideoId: episode.shortPlayVideoId,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
body: _bodyWidget(),
|
||||
);
|
||||
return Scaffold(backgroundColor: Colors.black, body: _bodyWidget());
|
||||
}
|
||||
|
||||
Widget _bodyWidget() {
|
||||
@@ -63,17 +72,29 @@ class _DramaDetailPageState extends State<DramaDetailPage> {
|
||||
|
||||
if (_detailBean != null)
|
||||
Positioned(
|
||||
bottom: 0, left: 0, right: 0, top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: SkyPlayerView(
|
||||
key: ValueKey(
|
||||
_selectedEpisode?.shortPlayVideoId ??
|
||||
_detailBean?.videoInfo?.shortPlayVideoId ??
|
||||
widget.dramaBean.shortPlayVideoId,
|
||||
),
|
||||
detailBean: _detailBean,
|
||||
dramaBean: widget.dramaBean,
|
||||
currentEpisode: _selectedEpisode?.episode,
|
||||
onSelectedEpisode: _onSelectedEpisode,
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: AppScreen.statusBarHeight + 5, left: 0, right: 0,
|
||||
top: AppScreen.statusBarHeight + 5,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: _headerWidget(),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -88,14 +109,18 @@ class _DramaDetailPageState extends State<DramaDetailPage> {
|
||||
icon: HelpImg.asset(ConstImg.back, width: 32),
|
||||
onPressed: () => HelpNav.back(),
|
||||
),
|
||||
Expanded(child: SkyText(text: widget.dramaBean.name, color: Colors.white, fontSize: 16,
|
||||
textAlign: TextAlign.center,
|
||||
fontWeight: FontWeight.bold,
|
||||
)),
|
||||
SizedBox(width: 40,)
|
||||
Expanded(
|
||||
child: SkyText(
|
||||
text: widget.dramaBean.name,
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
textAlign: TextAlign.center,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 40),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import 'package:skywood/utils/models/drama/skywood_episode.dart';
|
||||
import 'package:skywood/utils/tools/widgets/sky_common_widget.dart';
|
||||
|
||||
class DramaEspPage extends StatefulWidget {
|
||||
const DramaEspPage({super.key,
|
||||
const DramaEspPage({
|
||||
super.key,
|
||||
required this.detail,
|
||||
this.currentEpisode,
|
||||
this.onSelectedEpisode,
|
||||
@@ -14,7 +15,7 @@ class DramaEspPage extends StatefulWidget {
|
||||
|
||||
final SkywoodDetail detail;
|
||||
final int? currentEpisode;
|
||||
final Function(int)? onSelectedEpisode;
|
||||
final ValueChanged<SkywoodEpisode>? onSelectedEpisode;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -184,10 +185,11 @@ class _DramaEspPageState extends State<DramaEspPage> {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (_selectedEpisode == episode.episode) return;
|
||||
setState(() {
|
||||
_selectedEpisode = episode.episode;
|
||||
});
|
||||
widget.onSelectedEpisode?.call(_selectedEpisode);
|
||||
widget.onSelectedEpisode?.call(episode);
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:skywood/global/client/event_client.dart';
|
||||
import 'package:skywood/global/client/play_client.dart';
|
||||
import 'package:skywood/main/lib_file.dart';
|
||||
import 'package:skywood/pages/home/players/page/drama_esp_page.dart';
|
||||
@@ -15,6 +16,7 @@ class SkyPlayerView extends StatefulWidget {
|
||||
final SkywoodDetail? detailBean;
|
||||
final SkywoodDrama dramaBean;
|
||||
final int? currentEpisode;
|
||||
final ValueChanged<SkywoodEpisode>? onSelectedEpisode;
|
||||
|
||||
const SkyPlayerView({
|
||||
super.key,
|
||||
@@ -23,6 +25,7 @@ class SkyPlayerView extends StatefulWidget {
|
||||
this.detailBean,
|
||||
required this.dramaBean,
|
||||
this.currentEpisode,
|
||||
this.onSelectedEpisode,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -40,6 +43,8 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
Duration _totalDuration = Duration.zero;
|
||||
bool _isLiked = false;
|
||||
SkywoodEpisode? _currentEpisode;
|
||||
// 是否已经上报his
|
||||
bool _isReportedHis = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -47,14 +52,15 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
_initializePlayer();
|
||||
}
|
||||
|
||||
// @override
|
||||
// void didUpdateWidget(SkyPlayerView oldWidget) {
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
// if (oldWidget.videoUrl != widget.videoUrl) {
|
||||
// _disposeController();
|
||||
// _initializePlayer();
|
||||
// }
|
||||
// }
|
||||
@override
|
||||
void didUpdateWidget(SkyPlayerView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.detailBean != widget.detailBean ||
|
||||
oldWidget.currentEpisode != widget.currentEpisode) {
|
||||
_disposeController();
|
||||
_initializePlayer();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initializePlayer() async {
|
||||
setState(() {
|
||||
@@ -66,18 +72,10 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
_isLiked = widget.dramaBean.isCollect ?? false;
|
||||
});
|
||||
|
||||
int _esp = widget.currentEpisode ?? 0;
|
||||
String videoUrl = '';
|
||||
if (widget.detailBean != null) {
|
||||
if (widget.detailBean!.episodeList.isNotEmpty) {
|
||||
videoUrl = widget.detailBean!.episodeList[_esp].videoUrl;
|
||||
_currentEpisode = widget.detailBean!.episodeList[_esp];
|
||||
}
|
||||
}
|
||||
_currentEpisode = _resolveCurrentEpisode();
|
||||
String videoUrl = _currentEpisode?.videoUrl ?? '';
|
||||
|
||||
final controller = VideoPlayerController.networkUrl(
|
||||
Uri.parse(videoUrl),
|
||||
);
|
||||
final controller = VideoPlayerController.networkUrl(Uri.parse(videoUrl));
|
||||
_controller = controller;
|
||||
_controllerCreated = true;
|
||||
controller.addListener(_handlePlayerValueChanged);
|
||||
@@ -104,6 +102,17 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
void _handlePlayerValueChanged() {
|
||||
if (!mounted || !_controllerCreated) return;
|
||||
_syncPlayerValue();
|
||||
|
||||
final videoController = _controller;
|
||||
final position = videoController.value.position;
|
||||
final duration = videoController.value.duration;
|
||||
if (_isPlaying && !_isReportedHis && position.inSeconds > 1) {
|
||||
_isReportedHis = true;
|
||||
EventClient.eventCreateHis(
|
||||
shortPlayId: _currentEpisode!.shortPlayId.toString(),
|
||||
videoId: _currentEpisode!.shortPlayVideoId.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _syncPlayerValue() {
|
||||
@@ -194,9 +203,7 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
Widget _buildLoadingView() {
|
||||
return Container(
|
||||
color: Colors.black,
|
||||
child: Center(
|
||||
child: HelpImg.asset(ConstImg.loading, width: 110),
|
||||
),
|
||||
child: Center(child: HelpImg.asset(ConstImg.loading, width: 110)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -223,17 +230,39 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
}
|
||||
}
|
||||
|
||||
SkywoodEpisode? _resolveCurrentEpisode() {
|
||||
final detail = widget.detailBean;
|
||||
if (detail == null || detail.episodeList.isEmpty) return null;
|
||||
|
||||
final int? episode =
|
||||
widget.currentEpisode ??
|
||||
detail.videoInfo?.episode ??
|
||||
detail.videoInfo?.currentEpisode ??
|
||||
detail.shortPlayInfo?.episode ??
|
||||
detail.shortPlayInfo?.currentEpisode;
|
||||
|
||||
if (episode != null && episode > 0) {
|
||||
for (final item in detail.episodeList) {
|
||||
if (item.episode == episode) return item;
|
||||
}
|
||||
}
|
||||
|
||||
return detail.episodeList.first;
|
||||
}
|
||||
|
||||
void _collectionDrama() {
|
||||
if (_currentEpisode == null) return;
|
||||
if (_isLiked) {
|
||||
PlayClient.cancelCollect(shortPlayId: _currentEpisode!.shortPlayId).then((value) {
|
||||
PlayClient.cancelCollect(shortPlayId: _currentEpisode!.shortPlayId).then((
|
||||
value,
|
||||
) {
|
||||
setState(() {
|
||||
_isLiked = value;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
PlayClient.collect(
|
||||
shortPlayId: _currentEpisode!.shortPlayId,
|
||||
shortPlayId: _currentEpisode!.shortPlayId,
|
||||
videoId: _currentEpisode!.shortPlayVideoId,
|
||||
).then((value) {
|
||||
setState(() {
|
||||
@@ -257,8 +286,9 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
InkWell(
|
||||
onTap: () => _collectionDrama(),
|
||||
child: HelpImg.asset(
|
||||
_isLiked ? ConstImg.liked : ConstImg.unlike,
|
||||
width: 40, height: 40
|
||||
_isLiked ? ConstImg.liked : ConstImg.unlike,
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
@@ -282,7 +312,7 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
color: Colors.white,
|
||||
),
|
||||
SkyText(
|
||||
text: ' / EP.${detail.episodeList.length}',
|
||||
text: ' / EP.$totalEpisode',
|
||||
fontSize: 13,
|
||||
color: Colors.white.withAlpha(126),
|
||||
),
|
||||
@@ -293,9 +323,6 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
),
|
||||
).addInkWell(
|
||||
onTap: () {
|
||||
// HelpNav.showBottom(
|
||||
// DramaEspPage(detail: detail, currentEpisode: currentEpisode),
|
||||
// );
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
@@ -307,12 +334,8 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
detail: detail,
|
||||
currentEpisode: currentEpisode,
|
||||
onSelectedEpisode: (episode) {
|
||||
|
||||
if (widget.detailBean != null) {
|
||||
if (widget.detailBean!.episodeList.isNotEmpty) {
|
||||
_currentEpisode = widget.detailBean!.episodeList[episode];
|
||||
}
|
||||
}
|
||||
Navigator.pop(context);
|
||||
widget.onSelectedEpisode?.call(episode);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -361,9 +384,7 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
child: SliderTheme(
|
||||
data: SliderThemeData(
|
||||
trackHeight: 3, // ✅ 进度条高度 3
|
||||
thumbShape: _ImageThumbShape(
|
||||
imagePath: ConstImg.playTag
|
||||
),
|
||||
thumbShape: _ImageThumbShape(imagePath: ConstImg.playTag),
|
||||
overlayShape: const RoundSliderOverlayShape(overlayRadius: 3),
|
||||
activeTrackColor: Colors.white, // ✅ 已播放 = 白色
|
||||
inactiveTrackColor: Colors.white.withAlpha(126), // ✅ 未播放 = 灰色
|
||||
@@ -404,6 +425,10 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
}
|
||||
|
||||
int _getCurrentEpisode(SkywoodDetail detail) {
|
||||
if (_currentEpisode?.episode != null && _currentEpisode!.episode > 0) {
|
||||
return _currentEpisode!.episode;
|
||||
}
|
||||
|
||||
final int? episode =
|
||||
detail.videoInfo?.episode ??
|
||||
detail.videoInfo?.currentEpisode ??
|
||||
@@ -419,18 +444,11 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class _ImageThumbShape extends SliderComponentShape {
|
||||
final String imagePath;
|
||||
final double imageSize;
|
||||
final double imageSize = 16;
|
||||
|
||||
const _ImageThumbShape({
|
||||
required this.imagePath,
|
||||
this.imageSize = 16,
|
||||
});
|
||||
const _ImageThumbShape({required this.imagePath});
|
||||
|
||||
@override
|
||||
Size getPreferredSize(bool isEnabled, bool isDiscrete) {
|
||||
@@ -439,19 +457,19 @@ class _ImageThumbShape extends SliderComponentShape {
|
||||
|
||||
@override
|
||||
void paint(
|
||||
PaintingContext context,
|
||||
Offset center, {
|
||||
required Animation<double> activationAnimation,
|
||||
required Animation<double> enableAnimation,
|
||||
required bool isDiscrete,
|
||||
required TextPainter labelPainter,
|
||||
required RenderBox parentBox,
|
||||
required SliderThemeData sliderTheme,
|
||||
required TextDirection textDirection,
|
||||
required double value,
|
||||
required double textScaleFactor,
|
||||
required Size sizeWithOverflow,
|
||||
}) {
|
||||
PaintingContext context,
|
||||
Offset center, {
|
||||
required Animation<double> activationAnimation,
|
||||
required Animation<double> enableAnimation,
|
||||
required bool isDiscrete,
|
||||
required TextPainter labelPainter,
|
||||
required RenderBox parentBox,
|
||||
required SliderThemeData sliderTheme,
|
||||
required TextDirection textDirection,
|
||||
required double value,
|
||||
required double textScaleFactor,
|
||||
required Size sizeWithOverflow,
|
||||
}) {
|
||||
// 🔥 使用 Image 直接渲染图片
|
||||
final imageWidget = Image.asset(
|
||||
imagePath,
|
||||
@@ -464,29 +482,34 @@ class _ImageThumbShape extends SliderComponentShape {
|
||||
final stream = image.resolve(ImageConfiguration());
|
||||
|
||||
// 添加监听器,但只在图片加载完成后绘制
|
||||
stream.addListener(ImageStreamListener((imageInfo, _) {
|
||||
final rect = Rect.fromCenter(
|
||||
center: center,
|
||||
width: imageSize,
|
||||
height: imageSize,
|
||||
);
|
||||
context.canvas.drawImageRect(
|
||||
imageInfo.image,
|
||||
Rect.fromLTWH(
|
||||
0,
|
||||
0,
|
||||
imageInfo.image.width.toDouble(),
|
||||
imageInfo.image.height.toDouble(),
|
||||
),
|
||||
rect,
|
||||
Paint(),
|
||||
);
|
||||
}, onError: (error, stackTrace) {
|
||||
// 🔥 如果图片加载失败,绘制一个默认圆点
|
||||
final paint = Paint()
|
||||
..color = Colors.white
|
||||
..style = PaintingStyle.fill;
|
||||
context.canvas.drawCircle(center, imageSize / 2, paint);
|
||||
}));
|
||||
stream.addListener(
|
||||
ImageStreamListener(
|
||||
(imageInfo, _) {
|
||||
final rect = Rect.fromCenter(
|
||||
center: center,
|
||||
width: imageSize,
|
||||
height: imageSize,
|
||||
);
|
||||
context.canvas.drawImageRect(
|
||||
imageInfo.image,
|
||||
Rect.fromLTWH(
|
||||
0,
|
||||
0,
|
||||
imageInfo.image.width.toDouble(),
|
||||
imageInfo.image.height.toDouble(),
|
||||
),
|
||||
rect,
|
||||
Paint(),
|
||||
);
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
// 🔥 如果图片加载失败,绘制一个默认圆点
|
||||
final paint = Paint()
|
||||
..color = Colors.white
|
||||
..style = PaintingStyle.fill;
|
||||
context.canvas.drawCircle(center, imageSize / 2, paint);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user