Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-11 17:01:33 +08:00
parent 60c25e4b65
commit 17b7eb7e0f
4 changed files with 48 additions and 65 deletions

View File

@@ -46,21 +46,28 @@ class NetworkImgLayer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return src?.isNotEmpty == true
? type == ImageType.avatar
? ClipOval(child: _buildImage(context))
: radius == 0 || type == ImageType.emote
? _buildImage(context)
: ClipRRect(
borderRadius: radius != null
? BorderRadius.circular(radius!)
: StyleString.mdRadius,
child: _buildImage(context),
)
: getPlaceHolder?.call() ?? _placeholder(context);
final noRadius = type == ImageType.emote || radius == 0;
if (src?.isNotEmpty == true) {
Widget child = _buildImage(context, noRadius);
if (noRadius) {
return child;
}
if (type == ImageType.avatar) {
return ClipOval(child: child);
}
return ClipRRect(
borderRadius: radius != null
? BorderRadius.circular(radius!)
: StyleString.mdRadius,
child: child,
);
}
return getPlaceHolder?.call() ?? _placeholder(context, noRadius);
}
Widget _buildImage(BuildContext context) {
Widget _buildImage(BuildContext context, bool noRadius) {
int? memCacheWidth, memCacheHeight;
if (height == null || forceUseCacheWidth || width <= height!) {
memCacheWidth = width.cacheSize(context);
@@ -79,26 +86,26 @@ class NetworkImgLayer extends StatelessWidget {
fadeInDuration: fadeInDuration ?? const Duration(milliseconds: 120),
filterQuality: FilterQuality.low,
placeholder: (BuildContext context, String url) =>
getPlaceHolder?.call() ?? _placeholder(context),
getPlaceHolder?.call() ?? _placeholder(context, noRadius),
imageBuilder: imageBuilder,
errorWidget: (context, url, error) => _placeholder(context),
errorWidget: (context, url, error) => _placeholder(context, noRadius),
colorBlendMode: reduce ? BlendMode.modulate : null,
color: reduce ? reduceLuxColor : null,
);
}
Widget _placeholder(BuildContext context) {
Widget _placeholder(BuildContext context, bool noRadius) {
final isAvatar = type == ImageType.avatar;
return Container(
width: width,
height: height,
clipBehavior: Clip.antiAlias,
clipBehavior: noRadius ? Clip.none : Clip.antiAlias,
decoration: BoxDecoration(
shape: type == ImageType.avatar ? BoxShape.circle : BoxShape.rectangle,
shape: isAvatar ? BoxShape.circle : BoxShape.rectangle,
color: Theme.of(
context,
).colorScheme.onInverseSurface.withValues(alpha: 0.4),
borderRadius:
type == ImageType.avatar || type == ImageType.emote || radius == 0
borderRadius: noRadius || isAvatar
? null
: radius != null
? BorderRadius.circular(radius!)
@@ -106,9 +113,7 @@ class NetworkImgLayer extends StatelessWidget {
),
child: Center(
child: Image.asset(
type == ImageType.avatar
? 'assets/images/noface.jpeg'
: 'assets/images/loading.png',
isAvatar ? 'assets/images/noface.jpeg' : 'assets/images/loading.png',
width: width,
height: height,
cacheWidth: width.cacheSize(context),

View File

@@ -196,8 +196,7 @@ class LiveRoomController extends GetxController {
);
}
void scrollToBottom() {
if (disableAutoScroll.value) return;
void scrollToBottom([_]) {
if (scrollController.hasClients) {
scrollController.animateTo(
scrollController.position.maxScrollExtent,
@@ -231,9 +230,7 @@ class LiveRoomController extends GetxController {
},
),
);
WidgetsBinding.instance.addPostFrameCallback(
(_) => scrollToBottom(),
);
WidgetsBinding.instance.addPostFrameCallback(scrollToBottom);
} catch (_) {}
}
}
@@ -334,9 +331,9 @@ class LiveRoomController extends GetxController {
selfSend: isLogin && uid == accountService.mid,
),
);
if (!isFullScreen) {
if (!isFullScreen && !disableAutoScroll.value) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => scrollToBottom(),
scrollToBottom,
);
}
}

View File

@@ -1646,6 +1646,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
height: height,
boxFit: BoxFit.cover,
forceUseCacheWidth: true,
getPlaceHolder: () => Center(
child: Image.asset('assets/images/loading.png'),
),
),
),
),

View File

@@ -79,7 +79,7 @@ class PlPlayerController {
final Rx<Duration> _buffered = Rx(Duration.zero);
final RxInt bufferedSeconds = 0.obs;
final RxInt _playerCount = 0.obs;
int _playerCount = 0;
late double lastPlaybackSpeed = 1.0;
final RxDouble _playbackSpeed = Pref.playSpeedDefault.obs;
@@ -87,7 +87,6 @@ class PlPlayerController {
final RxDouble _currentVolume = 1.0.obs;
final RxDouble _currentBrightness = (-1.0).obs;
final RxBool _mute = false.obs;
final RxBool _showControls = false.obs;
final RxBool _showVolumeStatus = false.obs;
final RxBool _showBrightnessStatus = false.obs;
@@ -135,10 +134,7 @@ class PlPlayerController {
Timer? _timer;
Timer? _timerForSeek;
Timer? _timerForVolume;
Timer? _timerForShowingVolume;
Timer? _timerForGettingVolume;
Timer? timerForTrackingMouse;
final RxList<Segment> viewPointList = <Segment>[].obs;
final RxBool showVP = true.obs;
@@ -175,10 +171,6 @@ class PlPlayerController {
Rx<Duration> get buffered => _buffered;
Stream<Duration> get onBufferedChanged => _buffered.stream;
// 视频静音
RxBool get mute => _mute;
Stream<bool> get onMuteChanged => _mute.stream;
/// [videoPlayerController] instance of Player
Player? get videoPlayerController => _videoPlayerController;
@@ -249,8 +241,6 @@ class PlPlayerController {
/// 全屏方向
bool get isVertical => _isVertical;
RxInt get playerCount => _playerCount;
///
bool get isLive => _isLive;
@@ -510,7 +500,7 @@ class PlPlayerController {
_instance ??= PlPlayerController._();
_instance!
.._isLive = isLive
.._playerCount.value += 1;
.._playerCount += 1;
return _instance!;
}
@@ -580,7 +570,7 @@ class PlPlayerController {
await pause(notify: false);
}
if (_playerCount.value == 0) {
if (_playerCount == 0) {
return;
}
// 配置Player 音轨、字幕等等
@@ -1045,7 +1035,7 @@ class PlPlayerController {
// if (position >= duration.value) {
// position = duration.value - const Duration(milliseconds: 100);
// }
if (_playerCount.value == 0) {
if (_playerCount == 0) {
return;
}
if (position < Duration.zero) {
@@ -1075,7 +1065,7 @@ class PlPlayerController {
Timer t,
) async {
//_timerForSeek = null;
if (_playerCount.value == 0) {
if (_playerCount == 0) {
_timerForSeek?.cancel();
_timerForSeek = null;
} else if (duration.value.inSeconds != 0) {
@@ -1128,7 +1118,7 @@ class PlPlayerController {
/// 播放视频
Future<void> play({bool repeat = false, bool hideControls = true}) async {
if (_playerCount.value == 0) return;
if (_playerCount == 0) return;
// 播放时自动隐藏控制条
controls = !hideControls;
// repeat为true将从头播放
@@ -1170,9 +1160,7 @@ class PlPlayerController {
/// 隐藏控制条
void hideTaskControls() {
if (_timer != null) {
_timer!.cancel();
}
_timer?.cancel();
Duration waitingTime = Duration(seconds: enableLongShowControl ? 30 : 3);
_timer = Timer(waitingTime, () {
if (!isSliderMoving.value && !tripling) {
@@ -1446,14 +1434,6 @@ class PlPlayerController {
return screenshot;
}
Future<void> videoPlayerClosed() async {
_timer?.cancel();
_timerForVolume?.cancel();
_timerForGettingVolume?.cancel();
timerForTrackingMouse?.cancel();
_timerForSeek?.cancel();
}
// 记录播放记录
Future<void> makeHeartBeat(
int progress, {
@@ -1547,8 +1527,8 @@ class PlPlayerController {
Future<void> dispose() async {
// 每次减1最后销毁
if (playerCount.value > 1) {
_playerCount.value -= 1;
if (_playerCount > 1) {
_playerCount -= 1;
_heartDuration = 0;
if (!Get.previousRoute.startsWith('/video')) {
pause();
@@ -1556,15 +1536,13 @@ class PlPlayerController {
return;
}
dmState.clear();
_playerCount.value = 0;
_playerCount = 0;
Utils.channel.setMethodCallHandler(null);
pause();
try {
_timer?.cancel();
_timerForVolume?.cancel();
_timerForGettingVolume?.cancel();
timerForTrackingMouse?.cancel();
_timerForSeek?.cancel();
_timerForShowingVolume?.cancel();
// _position.close();
_playerEventSubs?.cancel();
// _sliderPosition.close();
@@ -1593,10 +1571,10 @@ class PlPlayerController {
}
static void updatePlayCount() {
if (_instance?._playerCount.value == 1) {
if (_instance?._playerCount == 1) {
_instance?.dispose();
} else {
_instance?._playerCount.value -= 1;
_instance?._playerCount -= 1;
}
}