|
|
@ -16,6 +16,7 @@ Widget buildMusicItem(BuildContext context, int id, String name, String url, |
|
|
'artist': singer, |
|
|
'artist': singer, |
|
|
'coverUrl': image, |
|
|
'coverUrl': image, |
|
|
}; |
|
|
}; |
|
|
|
|
|
controller.musicStatus(); //刷新状态 |
|
|
return Container( |
|
|
return Container( |
|
|
padding: const EdgeInsets.all(14), |
|
|
padding: const EdgeInsets.all(14), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
@ -81,7 +82,7 @@ Widget buildMusicItem(BuildContext context, int id, String name, String url, |
|
|
), |
|
|
), |
|
|
Obx(() { |
|
|
Obx(() { |
|
|
final isThisPlaying = |
|
|
final isThisPlaying = |
|
|
controller.isPlaying.value && controller.currentUrl.value == url; |
|
|
controller.isPlaying.value && controller.currentId.value == id; |
|
|
|
|
|
|
|
|
// 只有当前播放的歌曲才显示进度 |
|
|
// 只有当前播放的歌曲才显示进度 |
|
|
final currentProgress = |
|
|
final currentProgress = |
|
|
@ -97,7 +98,7 @@ Widget buildMusicItem(BuildContext context, int id, String name, String url, |
|
|
onPlayPause: () async { |
|
|
onPlayPause: () async { |
|
|
try { |
|
|
try { |
|
|
if (controller.isPlaying.value) { |
|
|
if (controller.isPlaying.value) { |
|
|
if (controller.currentUrl.value == url) { |
|
|
if (controller.currentId.value == id) { |
|
|
// 当前歌曲正在播放,暂停它 |
|
|
// 当前歌曲正在播放,暂停它 |
|
|
await controller.musicPause(); |
|
|
await controller.musicPause(); |
|
|
} else { |
|
|
} else { |
|
|
@ -105,7 +106,7 @@ Widget buildMusicItem(BuildContext context, int id, String name, String url, |
|
|
await controller.musicPlay(song); |
|
|
await controller.musicPlay(song); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if (controller.currentUrl.value == url) { |
|
|
if (controller.currentid.value == id) { |
|
|
// 当前歌曲已暂停,恢复播放 |
|
|
// 当前歌曲已暂停,恢复播放 |
|
|
await controller.musicResume(); |
|
|
await controller.musicResume(); |
|
|
} else { |
|
|
} else { |
|
|
|