Skip to content

Commit

Permalink
修复播放列表为空不能播放问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SQ committed Feb 7, 2024
1 parent 19b8865 commit 09916d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions lib/page/controller/ServiceController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,13 @@ class ServiceController extends GetxController {
playMusicEntity.lyric = getsongInfoById["musicLyric"];
var box = await Hive.openBox("playlist_nowPlaying");
box.put(id, playMusicEntity.toJson());
playlist.insert(currentPlayIndex.value+1, playMusicEntity);
currentPlayIndex.value = currentPlayIndex.value+1;
if(playlist.length==0){
playlist.add(playMusicEntity);
currentPlayIndex.value = 0;
}else{
playlist.insert(currentPlayIndex.value+1, playMusicEntity);
currentPlayIndex.value = currentPlayIndex.value+1;
}
updatePlayListSet();
await player.play(UrlSource(source));
musicID.value = playMusicEntity.id!;
Expand Down Expand Up @@ -278,8 +283,14 @@ class ServiceController extends GetxController {

var box = await Hive.openBox("playlist_nowPlaying");
box.put(id, playMusicEntity.toJson());
playlist.insert(currentPlayIndex.value+1, playMusicEntity);
currentPlayIndex.value = currentPlayIndex.value+1;

if(playlist.length==0){
playlist.add(playMusicEntity);
currentPlayIndex.value = 0;
}else{
playlist.insert(currentPlayIndex.value+1, playMusicEntity);
currentPlayIndex.value = currentPlayIndex.value+1;
}
updatePlayListSet();
await player.play(UrlSource(url));
musicID.value = playMusicEntity.id!;
Expand All @@ -297,8 +308,6 @@ class ServiceController extends GetxController {
jumpMusic(int playListIndex) async {
PlayMusicEntity music = playlist[playListIndex];



Hive.openBox("play_list_star_song").then((box) => {
if (box.get(music.id) != null) {isStar.value = true}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/page/left_widget/LeftWidge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class _LeftWidgeState extends State<LeftWidge> {
text: TextSpan(
children: [
TextSpan(
text:'版本号:v1.1.8',
text:'版本号:v1.1.9',
style: TextStyle(
color: Get.isDarkMode?dark_text_Colors:light_text_Colors,
),
Expand Down

0 comments on commit 09916d0

Please sign in to comment.