diff --git a/lib/ui/music_player.dart b/lib/ui/music_player.dart index 3b204f6..1ae8fc8 100644 --- a/lib/ui/music_player.dart +++ b/lib/ui/music_player.dart @@ -26,7 +26,11 @@ class _MusicPlayerState extends State { 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 stack = []; int currMusicPos = 0; @@ -54,9 +58,9 @@ class _MusicPlayerState extends State { videoPlayerController: _videoPlayerController!, autoPlay: true, showControls: false); - } - setState(() {}); + _videoPlayerController!.addListener(() => setState(() {})); + } } Future _stop() async { @@ -69,7 +73,6 @@ class _MusicPlayerState extends State { void _pause() async { await _chewieAudioController?.pause(); - setState(() {}); } void _playPrevious() async { @@ -154,6 +157,12 @@ class _MusicPlayerState extends State { 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(