mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
@@ -46,21 +46,28 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return src?.isNotEmpty == true
|
final noRadius = type == ImageType.emote || radius == 0;
|
||||||
? type == ImageType.avatar
|
|
||||||
? ClipOval(child: _buildImage(context))
|
if (src?.isNotEmpty == true) {
|
||||||
: radius == 0 || type == ImageType.emote
|
Widget child = _buildImage(context, noRadius);
|
||||||
? _buildImage(context)
|
if (noRadius) {
|
||||||
: ClipRRect(
|
return child;
|
||||||
borderRadius: radius != null
|
}
|
||||||
? BorderRadius.circular(radius!)
|
if (type == ImageType.avatar) {
|
||||||
: StyleString.mdRadius,
|
return ClipOval(child: child);
|
||||||
child: _buildImage(context),
|
}
|
||||||
)
|
return ClipRRect(
|
||||||
: getPlaceHolder?.call() ?? _placeholder(context);
|
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;
|
int? memCacheWidth, memCacheHeight;
|
||||||
if (height == null || forceUseCacheWidth || width <= height!) {
|
if (height == null || forceUseCacheWidth || width <= height!) {
|
||||||
memCacheWidth = width.cacheSize(context);
|
memCacheWidth = width.cacheSize(context);
|
||||||
@@ -79,26 +86,26 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
fadeInDuration: fadeInDuration ?? const Duration(milliseconds: 120),
|
fadeInDuration: fadeInDuration ?? const Duration(milliseconds: 120),
|
||||||
filterQuality: FilterQuality.low,
|
filterQuality: FilterQuality.low,
|
||||||
placeholder: (BuildContext context, String url) =>
|
placeholder: (BuildContext context, String url) =>
|
||||||
getPlaceHolder?.call() ?? _placeholder(context),
|
getPlaceHolder?.call() ?? _placeholder(context, noRadius),
|
||||||
imageBuilder: imageBuilder,
|
imageBuilder: imageBuilder,
|
||||||
errorWidget: (context, url, error) => _placeholder(context),
|
errorWidget: (context, url, error) => _placeholder(context, noRadius),
|
||||||
colorBlendMode: reduce ? BlendMode.modulate : null,
|
colorBlendMode: reduce ? BlendMode.modulate : null,
|
||||||
color: reduce ? reduceLuxColor : null,
|
color: reduce ? reduceLuxColor : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _placeholder(BuildContext context) {
|
Widget _placeholder(BuildContext context, bool noRadius) {
|
||||||
|
final isAvatar = type == ImageType.avatar;
|
||||||
return Container(
|
return Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: noRadius ? Clip.none : Clip.antiAlias,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: type == ImageType.avatar ? BoxShape.circle : BoxShape.rectangle,
|
shape: isAvatar ? BoxShape.circle : BoxShape.rectangle,
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
context,
|
context,
|
||||||
).colorScheme.onInverseSurface.withValues(alpha: 0.4),
|
).colorScheme.onInverseSurface.withValues(alpha: 0.4),
|
||||||
borderRadius:
|
borderRadius: noRadius || isAvatar
|
||||||
type == ImageType.avatar || type == ImageType.emote || radius == 0
|
|
||||||
? null
|
? null
|
||||||
: radius != null
|
: radius != null
|
||||||
? BorderRadius.circular(radius!)
|
? BorderRadius.circular(radius!)
|
||||||
@@ -106,9 +113,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
type == ImageType.avatar
|
isAvatar ? 'assets/images/noface.jpeg' : 'assets/images/loading.png',
|
||||||
? 'assets/images/noface.jpeg'
|
|
||||||
: 'assets/images/loading.png',
|
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
cacheWidth: width.cacheSize(context),
|
cacheWidth: width.cacheSize(context),
|
||||||
|
|||||||
@@ -196,8 +196,7 @@ class LiveRoomController extends GetxController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollToBottom() {
|
void scrollToBottom([_]) {
|
||||||
if (disableAutoScroll.value) return;
|
|
||||||
if (scrollController.hasClients) {
|
if (scrollController.hasClients) {
|
||||||
scrollController.animateTo(
|
scrollController.animateTo(
|
||||||
scrollController.position.maxScrollExtent,
|
scrollController.position.maxScrollExtent,
|
||||||
@@ -231,9 +230,7 @@ class LiveRoomController extends GetxController {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
WidgetsBinding.instance.addPostFrameCallback(scrollToBottom);
|
||||||
(_) => scrollToBottom(),
|
|
||||||
);
|
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,9 +331,9 @@ class LiveRoomController extends GetxController {
|
|||||||
selfSend: isLogin && uid == accountService.mid,
|
selfSend: isLogin && uid == accountService.mid,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (!isFullScreen) {
|
if (!isFullScreen && !disableAutoScroll.value) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
(_) => scrollToBottom(),
|
scrollToBottom,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1646,6 +1646,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
height: height,
|
height: height,
|
||||||
boxFit: BoxFit.cover,
|
boxFit: BoxFit.cover,
|
||||||
forceUseCacheWidth: true,
|
forceUseCacheWidth: true,
|
||||||
|
getPlaceHolder: () => Center(
|
||||||
|
child: Image.asset('assets/images/loading.png'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class PlPlayerController {
|
|||||||
final Rx<Duration> _buffered = Rx(Duration.zero);
|
final Rx<Duration> _buffered = Rx(Duration.zero);
|
||||||
final RxInt bufferedSeconds = 0.obs;
|
final RxInt bufferedSeconds = 0.obs;
|
||||||
|
|
||||||
final RxInt _playerCount = 0.obs;
|
int _playerCount = 0;
|
||||||
|
|
||||||
late double lastPlaybackSpeed = 1.0;
|
late double lastPlaybackSpeed = 1.0;
|
||||||
final RxDouble _playbackSpeed = Pref.playSpeedDefault.obs;
|
final RxDouble _playbackSpeed = Pref.playSpeedDefault.obs;
|
||||||
@@ -87,7 +87,6 @@ class PlPlayerController {
|
|||||||
final RxDouble _currentVolume = 1.0.obs;
|
final RxDouble _currentVolume = 1.0.obs;
|
||||||
final RxDouble _currentBrightness = (-1.0).obs;
|
final RxDouble _currentBrightness = (-1.0).obs;
|
||||||
|
|
||||||
final RxBool _mute = false.obs;
|
|
||||||
final RxBool _showControls = false.obs;
|
final RxBool _showControls = false.obs;
|
||||||
final RxBool _showVolumeStatus = false.obs;
|
final RxBool _showVolumeStatus = false.obs;
|
||||||
final RxBool _showBrightnessStatus = false.obs;
|
final RxBool _showBrightnessStatus = false.obs;
|
||||||
@@ -135,10 +134,7 @@ class PlPlayerController {
|
|||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
Timer? _timerForSeek;
|
Timer? _timerForSeek;
|
||||||
Timer? _timerForVolume;
|
|
||||||
Timer? _timerForShowingVolume;
|
Timer? _timerForShowingVolume;
|
||||||
Timer? _timerForGettingVolume;
|
|
||||||
Timer? timerForTrackingMouse;
|
|
||||||
|
|
||||||
final RxList<Segment> viewPointList = <Segment>[].obs;
|
final RxList<Segment> viewPointList = <Segment>[].obs;
|
||||||
final RxBool showVP = true.obs;
|
final RxBool showVP = true.obs;
|
||||||
@@ -175,10 +171,6 @@ class PlPlayerController {
|
|||||||
Rx<Duration> get buffered => _buffered;
|
Rx<Duration> get buffered => _buffered;
|
||||||
Stream<Duration> get onBufferedChanged => _buffered.stream;
|
Stream<Duration> get onBufferedChanged => _buffered.stream;
|
||||||
|
|
||||||
// 视频静音
|
|
||||||
RxBool get mute => _mute;
|
|
||||||
Stream<bool> get onMuteChanged => _mute.stream;
|
|
||||||
|
|
||||||
/// [videoPlayerController] instance of Player
|
/// [videoPlayerController] instance of Player
|
||||||
Player? get videoPlayerController => _videoPlayerController;
|
Player? get videoPlayerController => _videoPlayerController;
|
||||||
|
|
||||||
@@ -249,8 +241,6 @@ class PlPlayerController {
|
|||||||
/// 全屏方向
|
/// 全屏方向
|
||||||
bool get isVertical => _isVertical;
|
bool get isVertical => _isVertical;
|
||||||
|
|
||||||
RxInt get playerCount => _playerCount;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
bool get isLive => _isLive;
|
bool get isLive => _isLive;
|
||||||
|
|
||||||
@@ -510,7 +500,7 @@ class PlPlayerController {
|
|||||||
_instance ??= PlPlayerController._();
|
_instance ??= PlPlayerController._();
|
||||||
_instance!
|
_instance!
|
||||||
.._isLive = isLive
|
.._isLive = isLive
|
||||||
.._playerCount.value += 1;
|
.._playerCount += 1;
|
||||||
return _instance!;
|
return _instance!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,7 +570,7 @@ class PlPlayerController {
|
|||||||
await pause(notify: false);
|
await pause(notify: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_playerCount.value == 0) {
|
if (_playerCount == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 配置Player 音轨、字幕等等
|
// 配置Player 音轨、字幕等等
|
||||||
@@ -1045,7 +1035,7 @@ class PlPlayerController {
|
|||||||
// if (position >= duration.value) {
|
// if (position >= duration.value) {
|
||||||
// position = duration.value - const Duration(milliseconds: 100);
|
// position = duration.value - const Duration(milliseconds: 100);
|
||||||
// }
|
// }
|
||||||
if (_playerCount.value == 0) {
|
if (_playerCount == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (position < Duration.zero) {
|
if (position < Duration.zero) {
|
||||||
@@ -1075,7 +1065,7 @@ class PlPlayerController {
|
|||||||
Timer t,
|
Timer t,
|
||||||
) async {
|
) async {
|
||||||
//_timerForSeek = null;
|
//_timerForSeek = null;
|
||||||
if (_playerCount.value == 0) {
|
if (_playerCount == 0) {
|
||||||
_timerForSeek?.cancel();
|
_timerForSeek?.cancel();
|
||||||
_timerForSeek = null;
|
_timerForSeek = null;
|
||||||
} else if (duration.value.inSeconds != 0) {
|
} else if (duration.value.inSeconds != 0) {
|
||||||
@@ -1128,7 +1118,7 @@ class PlPlayerController {
|
|||||||
|
|
||||||
/// 播放视频
|
/// 播放视频
|
||||||
Future<void> play({bool repeat = false, bool hideControls = true}) async {
|
Future<void> play({bool repeat = false, bool hideControls = true}) async {
|
||||||
if (_playerCount.value == 0) return;
|
if (_playerCount == 0) return;
|
||||||
// 播放时自动隐藏控制条
|
// 播放时自动隐藏控制条
|
||||||
controls = !hideControls;
|
controls = !hideControls;
|
||||||
// repeat为true,将从头播放
|
// repeat为true,将从头播放
|
||||||
@@ -1170,9 +1160,7 @@ class PlPlayerController {
|
|||||||
|
|
||||||
/// 隐藏控制条
|
/// 隐藏控制条
|
||||||
void hideTaskControls() {
|
void hideTaskControls() {
|
||||||
if (_timer != null) {
|
_timer?.cancel();
|
||||||
_timer!.cancel();
|
|
||||||
}
|
|
||||||
Duration waitingTime = Duration(seconds: enableLongShowControl ? 30 : 3);
|
Duration waitingTime = Duration(seconds: enableLongShowControl ? 30 : 3);
|
||||||
_timer = Timer(waitingTime, () {
|
_timer = Timer(waitingTime, () {
|
||||||
if (!isSliderMoving.value && !tripling) {
|
if (!isSliderMoving.value && !tripling) {
|
||||||
@@ -1446,14 +1434,6 @@ class PlPlayerController {
|
|||||||
return screenshot;
|
return screenshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> videoPlayerClosed() async {
|
|
||||||
_timer?.cancel();
|
|
||||||
_timerForVolume?.cancel();
|
|
||||||
_timerForGettingVolume?.cancel();
|
|
||||||
timerForTrackingMouse?.cancel();
|
|
||||||
_timerForSeek?.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 记录播放记录
|
// 记录播放记录
|
||||||
Future<void> makeHeartBeat(
|
Future<void> makeHeartBeat(
|
||||||
int progress, {
|
int progress, {
|
||||||
@@ -1547,8 +1527,8 @@ class PlPlayerController {
|
|||||||
|
|
||||||
Future<void> dispose() async {
|
Future<void> dispose() async {
|
||||||
// 每次减1,最后销毁
|
// 每次减1,最后销毁
|
||||||
if (playerCount.value > 1) {
|
if (_playerCount > 1) {
|
||||||
_playerCount.value -= 1;
|
_playerCount -= 1;
|
||||||
_heartDuration = 0;
|
_heartDuration = 0;
|
||||||
if (!Get.previousRoute.startsWith('/video')) {
|
if (!Get.previousRoute.startsWith('/video')) {
|
||||||
pause();
|
pause();
|
||||||
@@ -1556,15 +1536,13 @@ class PlPlayerController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dmState.clear();
|
dmState.clear();
|
||||||
_playerCount.value = 0;
|
_playerCount = 0;
|
||||||
Utils.channel.setMethodCallHandler(null);
|
Utils.channel.setMethodCallHandler(null);
|
||||||
pause();
|
pause();
|
||||||
try {
|
try {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timerForVolume?.cancel();
|
|
||||||
_timerForGettingVolume?.cancel();
|
|
||||||
timerForTrackingMouse?.cancel();
|
|
||||||
_timerForSeek?.cancel();
|
_timerForSeek?.cancel();
|
||||||
|
_timerForShowingVolume?.cancel();
|
||||||
// _position.close();
|
// _position.close();
|
||||||
_playerEventSubs?.cancel();
|
_playerEventSubs?.cancel();
|
||||||
// _sliderPosition.close();
|
// _sliderPosition.close();
|
||||||
@@ -1593,10 +1571,10 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void updatePlayCount() {
|
static void updatePlayCount() {
|
||||||
if (_instance?._playerCount.value == 1) {
|
if (_instance?._playerCount == 1) {
|
||||||
_instance?.dispose();
|
_instance?.dispose();
|
||||||
} else {
|
} else {
|
||||||
_instance?._playerCount.value -= 1;
|
_instance?._playerCount -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user