Add slider

This commit is contained in:
Pierre HUBERT 2022-03-24 11:43:02 +01:00
parent 30aa018bed
commit aa3f743eee

View File

@ -26,7 +26,11 @@ class _MusicPlayerState extends State<MusicPlayer> {
VideoPlayerController? _videoPlayerController;
ChewieAudioController? _chewieAudioController;
bool get _isPlaying => _chewieAudioController?.isPlaying ?? false;
bool get _isPlaying => _videoPlayerController?.value.isPlaying ?? false;
Duration? get _duration => _videoPlayerController?.value.duration;
Duration? get _position => _videoPlayerController?.value.position;
final List<MusicEntry> stack = [];
int currMusicPos = 0;
@ -54,9 +58,9 @@ class _MusicPlayerState extends State<MusicPlayer> {
videoPlayerController: _videoPlayerController!,
autoPlay: true,
showControls: false);
}
setState(() {});
_videoPlayerController!.addListener(() => setState(() {}));
}
}
Future<void> _stop() async {
@ -69,7 +73,6 @@ class _MusicPlayerState extends State<MusicPlayer> {
void _pause() async {
await _chewieAudioController?.pause();
setState(() {});
}
void _playPrevious() async {
@ -154,6 +157,12 @@ class _MusicPlayerState extends State<MusicPlayer> {
const SizedBox(height: 20),
Text(currMusic.artist, textAlign: TextAlign.center),
const fluent.SizedBox(height: 40),
fluent.Slider(
max: _duration?.inSeconds as double? ?? 0,
value: _position?.inSeconds as double? ?? 0,
onChanged: (d) => {},
),
const fluent.SizedBox(height: 40),
fluent.Row(
children: [
IconButton(