parent
8692527105
commit
272241f338
3 changed files with 8 additions and 2 deletions
|
|
@ -43,6 +43,7 @@ class const AudioPlayer(
|
||||||
child: PlayerControls(
|
child: PlayerControls(
|
||||||
player,
|
player,
|
||||||
loading: !loaded.value,
|
loading: !loaded.value,
|
||||||
|
size: info?.size,
|
||||||
actions: .new([
|
actions: .new([
|
||||||
SizedBox(width: 4),
|
SizedBox(width: 4),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,14 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:flutter_hooks/flutter_hooks.dart";
|
import "package:flutter_hooks/flutter_hooks.dart";
|
||||||
import "package:material_ui/material_ui.dart";
|
import "package:material_ui/material_ui.dart";
|
||||||
import "package:media_kit/media_kit.dart";
|
import "package:media_kit/media_kit.dart";
|
||||||
|
import "package:nexus/helpers/extensions/size_to_string.dart";
|
||||||
|
|
||||||
/// Play/pause, position and seeking controls for a media_kit [Player].
|
/// Play/pause, position and seeking controls for a media_kit [Player].
|
||||||
class const PlayerControls(
|
class const PlayerControls(
|
||||||
final Player player, {
|
final Player player, {
|
||||||
final bool loading = false,
|
final bool loading = false,
|
||||||
final Color? color,
|
final Color? color,
|
||||||
|
final int? size,
|
||||||
final IList<Widget> actions = const .empty(),
|
final IList<Widget> actions = const .empty(),
|
||||||
super.key,
|
super.key,
|
||||||
}) extends HookWidget {
|
}) extends HookWidget {
|
||||||
|
|
@ -45,6 +47,8 @@ class const PlayerControls(
|
||||||
return "$minutes:$seconds";
|
return "$minutes:$seconds";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final sizeSuffix = size == null ? "" : " (${size!.sizeAsString})";
|
||||||
|
|
||||||
final textStyle = Theme.of(context).textTheme.bodySmall
|
final textStyle = Theme.of(context).textTheme.bodySmall
|
||||||
?.copyWith(color: color);
|
?.copyWith(color: color);
|
||||||
final max = duration.inMilliseconds <= 0
|
final max = duration.inMilliseconds <= 0
|
||||||
|
|
@ -84,7 +88,7 @@ class const PlayerControls(
|
||||||
playButton,
|
playButton,
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
"${format(position)} / ${format(duration)}",
|
"${format(position)} / ${format(duration)}$sizeSuffix",
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: .ellipsis,
|
overflow: .ellipsis,
|
||||||
|
|
@ -102,7 +106,7 @@ class const PlayerControls(
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text(format(position), style: textStyle),
|
Text(format(position), style: textStyle),
|
||||||
Expanded(child: slider()),
|
Expanded(child: slider()),
|
||||||
Text(format(duration), style: textStyle),
|
Text("${format(duration)}$sizeSuffix", style: textStyle),
|
||||||
...actions,
|
...actions,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ class const VideoPlayer(
|
||||||
child: PlayerControls(
|
child: PlayerControls(
|
||||||
player,
|
player,
|
||||||
loading: !loaded.value,
|
loading: !loaded.value,
|
||||||
|
size: info?.size,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
actions: .new([
|
actions: .new([
|
||||||
Builder(
|
Builder(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue