9dfa06ffee
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Signed-off-by: cls_宁波本机 <908705107@qq.com>
143 lines
4.9 KiB
Dart
143 lines
4.9 KiB
Dart
part of '../media_viewer_page.dart';
|
|
|
|
/// Video transport and message actions, kept visually aligned with the image
|
|
/// viewer chrome while the native player owns decoding and playback.
|
|
class _VideoViewerBottomControls extends StatelessWidget {
|
|
final VideoPlayerController? controller;
|
|
final VoidCallback? onReply;
|
|
|
|
const _VideoViewerBottomControls({
|
|
required this.controller,
|
|
required this.onReply,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final readyController = controller?.value.isInitialized == true
|
|
? controller
|
|
: null;
|
|
return Padding(
|
|
padding: const EdgeInsets.fromLTRB(Grid.sm, Grid.xxs, Grid.sm, 0),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (readyController != null)
|
|
_VideoTransportBar(controller: readyController),
|
|
Row(
|
|
children: [
|
|
_MediaViewerCircleButton(
|
|
key: const ValueKey('message-media-video-viewer-reply-thread'),
|
|
icon: LucideIcons.messageSquareReply,
|
|
tooltip: context.l10n.replyInThread,
|
|
onPressed: onReply,
|
|
),
|
|
const Spacer(),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _VideoTransportBar extends HookConsumerWidget {
|
|
final VideoPlayerController controller;
|
|
|
|
const _VideoTransportBar({required this.controller});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
useListenable(controller);
|
|
final value = controller.value;
|
|
final durationMs = value.duration.inMilliseconds;
|
|
final positionMs = value.position.inMilliseconds.clamp(0, durationMs);
|
|
final hasDuration = durationMs > 0;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: Grid.xxs),
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: Colors.black.withValues(alpha: 0.42),
|
|
border: Border.all(color: Colors.white.withValues(alpha: 0.12)),
|
|
borderRadius: BorderRadius.circular(Radii.full),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: Grid.xxs),
|
|
child: Row(
|
|
children: [
|
|
IconButton(
|
|
key: const ValueKey('message-media-video-viewer-play-pause'),
|
|
onPressed: () {
|
|
if (value.isPlaying) {
|
|
controller.pause();
|
|
} else {
|
|
controller.play();
|
|
}
|
|
},
|
|
tooltip: value.isPlaying
|
|
? context.l10n.pauseVideo
|
|
: context.l10n.playVideo,
|
|
icon: Icon(
|
|
value.isPlaying ? LucideIcons.pause : LucideIcons.play,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
Text(
|
|
_formatVideoDuration(Duration(milliseconds: positionMs)),
|
|
style: context.textTheme.labelSmall?.copyWith(
|
|
color: Colors.white,
|
|
fontFeatures: const [FontFeature.tabularFigures()],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: SliderTheme(
|
|
data: SliderTheme.of(context).copyWith(
|
|
activeTrackColor: Colors.white,
|
|
inactiveTrackColor: Colors.white.withValues(alpha: 0.28),
|
|
thumbColor: Colors.white,
|
|
overlayColor: Colors.white.withValues(alpha: 0.12),
|
|
trackHeight: 3,
|
|
thumbShape: const RoundSliderThumbShape(
|
|
enabledThumbRadius: 5,
|
|
),
|
|
),
|
|
child: Slider(
|
|
value: hasDuration ? positionMs.toDouble() : 0,
|
|
min: 0,
|
|
max: hasDuration ? durationMs.toDouble() : 1,
|
|
onChanged: hasDuration
|
|
? (next) => controller.seekTo(
|
|
Duration(milliseconds: next.round()),
|
|
)
|
|
: null,
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
_formatVideoDuration(value.duration),
|
|
style: context.textTheme.labelSmall?.copyWith(
|
|
color: Colors.white.withValues(alpha: 0.78),
|
|
fontFeatures: const [FontFeature.tabularFigures()],
|
|
),
|
|
),
|
|
const SizedBox(width: Grid.xxs),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
String _formatVideoDuration(Duration duration) {
|
|
final totalSeconds = duration.inSeconds.clamp(0, 359999);
|
|
final hours = totalSeconds ~/ 3600;
|
|
final minutes = (totalSeconds % 3600) ~/ 60;
|
|
final seconds = totalSeconds % 60;
|
|
final paddedSeconds = seconds.toString().padLeft(2, '0');
|
|
if (hours > 0) {
|
|
return '$hours:${minutes.toString().padLeft(2, '0')}:$paddedSeconds';
|
|
}
|
|
return '$minutes:$paddedSeconds';
|
|
}
|