mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +01:00
Show video position & length
This commit is contained in:
parent
225b8c6f5c
commit
2edc989a76
1 changed files with 32 additions and 0 deletions
|
@ -158,6 +158,18 @@ class _VideoViewerState extends State<VideoViewer> {
|
|||
type: MaterialType.transparency,
|
||||
child: Row(
|
||||
children: [
|
||||
ValueListenableBuilder(
|
||||
valueListenable: _controller,
|
||||
builder: (context, VideoPlayerValue value, child) =>
|
||||
Text(
|
||||
_durationToString(value.position),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: VideoProgressIndicator(
|
||||
_controller,
|
||||
|
@ -171,6 +183,15 @@ class _VideoViewerState extends State<VideoViewer> {
|
|||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
if (_controller.value.duration != Duration.zero)
|
||||
Text(
|
||||
_durationToString(_controller.value.duration),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
InkWell(
|
||||
borderRadius: BorderRadius.all(Radius.circular(32)),
|
||||
onTap: _onVolumnPressed,
|
||||
|
@ -266,3 +287,14 @@ class _VideoViewerState extends State<VideoViewer> {
|
|||
|
||||
static final _log = Logger("widget.video_viewer._VideoViewerState");
|
||||
}
|
||||
|
||||
String _durationToString(Duration duration) {
|
||||
String product = "";
|
||||
if (duration.inHours > 0) {
|
||||
product += "${duration.inHours}:";
|
||||
}
|
||||
final minStr = (duration.inMinutes % 60).toString().padLeft(2, "0");
|
||||
final secStr = (duration.inSeconds % 60).toString().padLeft(2, "0");
|
||||
product += "$minStr:$secStr";
|
||||
return product;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue