Display media size
This commit is contained in:
parent
545d9a951f
commit
1ff98b7bbf
@ -11,6 +11,12 @@ import 'package:music_web_player/api.dart';
|
|||||||
import 'package:music_web_player/ui/cover_image.dart';
|
import 'package:music_web_player/ui/cover_image.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
|
|
||||||
|
extension DurationExt on Duration {
|
||||||
|
String get formatted {
|
||||||
|
return "$inMinutes:${(inSeconds % 60).toString().padLeft(2, '0')}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MusicPlayer extends StatefulWidget {
|
class MusicPlayer extends StatefulWidget {
|
||||||
final MusicsList musicsList;
|
final MusicsList musicsList;
|
||||||
|
|
||||||
@ -167,12 +173,22 @@ class _MusicPlayerState extends State<MusicPlayer> {
|
|||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(currMusic.artist, textAlign: TextAlign.center),
|
Text(currMusic.artist, textAlign: TextAlign.center),
|
||||||
const fluent.SizedBox(height: 40),
|
const fluent.SizedBox(height: 40),
|
||||||
fluent.Slider(
|
fluent.Row(
|
||||||
max: _duration?.inSeconds as double? ?? 0,
|
children: [
|
||||||
value: _position?.inSeconds as double? ?? 0,
|
DurationText(_position),
|
||||||
onChanged: (d) => _updatePosition(Duration(seconds: d.toInt())),
|
const SizedBox(width: 15),
|
||||||
label:
|
Flexible(
|
||||||
"${_position?.inMinutes.toString().padLeft(2, '0')} : ${((_position?.inSeconds ?? 0) % 60).toString().padLeft(2, '0')}",
|
child: fluent.Slider(
|
||||||
|
max: _duration?.inSeconds as double? ?? 0,
|
||||||
|
value: _position?.inSeconds as double? ?? 0,
|
||||||
|
onChanged: (d) =>
|
||||||
|
_updatePosition(Duration(seconds: d.toInt())),
|
||||||
|
label: _position?.formatted,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 15),
|
||||||
|
DurationText(_duration),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const fluent.SizedBox(height: 40),
|
const fluent.SizedBox(height: 40),
|
||||||
fluent.Row(
|
fluent.Row(
|
||||||
@ -210,3 +226,17 @@ class PlayerIcon extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Icon(icon, size: 35);
|
Widget build(BuildContext context) => Icon(icon, size: 35);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DurationText extends StatelessWidget {
|
||||||
|
final Duration? duration;
|
||||||
|
|
||||||
|
const DurationText(this.duration, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Text(
|
||||||
|
duration?.formatted ?? "0:00",
|
||||||
|
style: const TextStyle(fontSize: 10),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user