fix: loading song covers correctly
This commit is contained in:
parent
b1db0059eb
commit
664dc7fd27
2 changed files with 82 additions and 30 deletions
|
@ -201,7 +201,9 @@ class AudioPlayerService {
|
||||||
initialPosition: Duration.zero,
|
initialPosition: Duration.zero,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
songNotifier.value = _songList[queuePast.length];
|
||||||
playerKey.currentState?.update();
|
playerKey.currentState?.update();
|
||||||
|
await _setColorScheme();
|
||||||
resume();
|
resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@ import 'package:responsive_sizer/responsive_sizer.dart';
|
||||||
import 'package:shimmer/shimmer.dart';
|
import 'package:shimmer/shimmer.dart';
|
||||||
import 'package:text_scroll/text_scroll.dart';
|
import 'package:text_scroll/text_scroll.dart';
|
||||||
|
|
||||||
/// The player widget
|
/// The player control widget
|
||||||
///
|
///
|
||||||
/// Showcases the playing song's details and features playback controls
|
/// Showcases the playing song's details and features playback controls
|
||||||
class Player extends StatefulWidget {
|
class Player extends StatefulWidget {
|
||||||
/// The player widget
|
/// The player control widget
|
||||||
///
|
///
|
||||||
/// Showcases the playing song's details and features playback controls
|
/// Showcases the playing song's details and features playback controls
|
||||||
const Player({super.key});
|
const Player({super.key});
|
||||||
|
@ -54,10 +54,7 @@ class PlayerState extends State<Player> {
|
||||||
controller: s,
|
controller: s,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
AnimatedOpacity(
|
ClipRRect(
|
||||||
opacity: _showFullControls ? 0 : 1,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -71,8 +68,11 @@ class PlayerState extends State<Player> {
|
||||||
color: Theme.of(context).colorScheme.primaryContainer,
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
height: 10.h,
|
height: 10.h,
|
||||||
width: 100.w,
|
width: 100.w,
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
opacity: _showFullControls ? 0 : 1,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ValueListenableBuilder<Song?>(
|
child: ValueListenableBuilder<Song?>(
|
||||||
valueListenable: songNotifier,
|
valueListenable: songNotifier,
|
||||||
builder: (c, t, w) {
|
builder: (c, t, w) {
|
||||||
|
@ -82,7 +82,7 @@ class PlayerState extends State<Player> {
|
||||||
height: 10.h,
|
height: 10.h,
|
||||||
width: 10.h,
|
width: 10.h,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(16),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
child: (t == null)
|
child: (t == null)
|
||||||
? ColoredBox(
|
? ColoredBox(
|
||||||
|
@ -224,18 +224,18 @@ class PlayerState extends State<Player> {
|
||||||
width: 80.w,
|
width: 80.w,
|
||||||
height: 80.w,
|
height: 80.w,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
// borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: (AudioPlayerService().song == null)
|
child: (AudioPlayerService().song == null)
|
||||||
? ColoredBox(
|
? ColoredBox(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.primaryContainer,
|
.secondaryContainer,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.music_note,
|
Icons.music_note,
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.onPrimaryContainer,
|
.onSecondaryContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -258,13 +258,13 @@ class PlayerState extends State<Player> {
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.primaryContainer,
|
.secondaryContainer,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.music_note,
|
Icons.music_note,
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.onPrimaryContainer,
|
.onSecondaryContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -297,7 +297,7 @@ class PlayerState extends State<Player> {
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 70.w,
|
width: 70.w,
|
||||||
height: 50,
|
height: 30,
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
AudioPlayerService().song?.artistName ?? "Nobody",
|
AudioPlayerService().song?.artistName ?? "Nobody",
|
||||||
style: TextStyle(fontSize: 16.sp),
|
style: TextStyle(fontSize: 16.sp),
|
||||||
|
@ -310,9 +310,6 @@ class PlayerState extends State<Player> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 60.w,
|
width: 60.w,
|
||||||
height: 40,
|
height: 40,
|
||||||
|
@ -342,6 +339,59 @@ class PlayerState extends State<Player> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 60.w,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
AudioPlayerService().previous();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.skip_previous,
|
||||||
|
size: 36,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
if (AudioPlayerService().song == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (AudioPlayerService().isPlaying) {
|
||||||
|
await AudioPlayerService().pause();
|
||||||
|
} else {
|
||||||
|
AudioPlayerService().resume();
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
icon: AnimatedCrossFade(
|
||||||
|
firstChild: const Icon(
|
||||||
|
Icons.play_arrow,
|
||||||
|
size: 36, // TODO: adapt to display size
|
||||||
|
),
|
||||||
|
secondChild: const Icon(Icons.pause, size: 36),
|
||||||
|
crossFadeState: (AudioPlayerService().isPlaying)
|
||||||
|
? CrossFadeState.showSecond
|
||||||
|
: CrossFadeState.showFirst,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
AudioPlayerService().next();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.skip_next,
|
||||||
|
size: 36,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue