mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-08 18:54:44 +00:00
下一首播放时的处理
This commit is contained in:
1 parent
126a32ab60
commit
df304d4d89
3 files changed
+39
-15
No files matched your search
@@ -582,5 +582,14 @@ public class PlayMusic {
|
||||
public static void clearNowPlayer() {
|
||||
nowPlayPlayer.clear();
|
||||
}
|
||||
|
||||
public static SongInfoObj getNextMusic() {
|
||||
synchronized (playList) {
|
||||
if (playList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return playList.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,13 +60,7 @@ public class PlayRuntime {
|
||||
private static void clear() {
|
||||
isPlay = false;
|
||||
|
||||
VoteItem vote = PlayMusic.getVote();
|
||||
if (vote != null && vote.getType() == VoteItem.VoteType.NEXT
|
||||
&& vote.getApi().equalsIgnoreCase(PlayMusic.nowPlayMusic.getApi())
|
||||
&& vote.getId().equalsIgnoreCase(PlayMusic.nowPlayMusic.getId())) {
|
||||
AllMusic.side.broadcastInTask(AllMusic.getMessage().vote.cancel1);
|
||||
PlayMusic.removeVote();
|
||||
}
|
||||
checkVoteNext();
|
||||
|
||||
PlayMusic.musicNowTime = 0;
|
||||
PlayMusic.musicAllTime = 0;
|
||||
@@ -80,6 +74,28 @@ public class PlayRuntime {
|
||||
HudUtils.sendHudLyricData();
|
||||
}
|
||||
|
||||
private static void checkVoteNext() {
|
||||
VoteItem vote = PlayMusic.getVote();
|
||||
if (vote != null && vote.getType() == VoteItem.VoteType.NEXT
|
||||
&& vote.getApi().equalsIgnoreCase(PlayMusic.nowPlayMusic.getApi())
|
||||
&& vote.getId().equalsIgnoreCase(PlayMusic.nowPlayMusic.getId())) {
|
||||
AllMusic.side.broadcastInTask(AllMusic.getMessage().vote.cancel1);
|
||||
PlayMusic.removeVote();
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkVotePush() {
|
||||
VoteItem vote = PlayMusic.getVote();
|
||||
SongInfoObj next = PlayMusic.getNextMusic();
|
||||
if (vote != null && next != null) {
|
||||
if (vote.getType() == VoteItem.VoteType.PUSH
|
||||
&& vote.getId().equalsIgnoreCase(next.getId())
|
||||
&& vote.getApi().equalsIgnoreCase(next.getApi())) {
|
||||
PlayMusic.removeVote();
|
||||
AllMusic.side.broadcastInTask(AllMusic.getMessage().push.cancel2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 歌曲时间定时器
|
||||
@@ -120,14 +136,6 @@ public class PlayRuntime {
|
||||
return Math.min(AllMusic.getConfig().vote.minVote, AllMusic.side.getPlayers().size());
|
||||
}
|
||||
|
||||
public static boolean checkMusic(String id, String api) {
|
||||
if (PlayMusic.nowPlayMusic.getId().equalsIgnoreCase(id)
|
||||
&& PlayMusic.nowPlayMusic.getApi().equalsIgnoreCase(api)) {
|
||||
return true;
|
||||
}
|
||||
return PlayMusic.getMusic(id, api) != null;
|
||||
}
|
||||
|
||||
private static void sendVoteInfo(boolean timeout) {
|
||||
if (timeout) {
|
||||
VoteItem vote = PlayMusic.getVote();
|
||||
@@ -229,6 +237,8 @@ public class PlayRuntime {
|
||||
continue;
|
||||
}
|
||||
|
||||
checkVotePush();
|
||||
|
||||
IMusicApi api = AllMusic.MUSIC_APIS.get(PlayMusic.nowPlayMusic.getApi());
|
||||
|
||||
PlayMusic.url = PlayMusic.nowPlayMusic.getPlayerUrl() == null ?
|
||||
|
||||
@@ -12,6 +12,7 @@ public class PushObj {
|
||||
public String pushErr;
|
||||
public String cancel;
|
||||
public String cancel1;
|
||||
public String cancel2;
|
||||
public String err1;
|
||||
public String err3;
|
||||
public String err4;
|
||||
@@ -53,6 +54,8 @@ public class PushObj {
|
||||
return true;
|
||||
if (cancel1 == null)
|
||||
return true;
|
||||
if (cancel2 == null)
|
||||
return true;
|
||||
return doPush == null;
|
||||
}
|
||||
|
||||
@@ -85,5 +88,7 @@ public class PushObj {
|
||||
cancel = "<light_purple>[AllMusic]<yellow>插歌投票已被发起者取消";
|
||||
if (cancel1 == null)
|
||||
cancel1 = "<light_purple>[AllMusic]<yellow>已删除你发起的投票";
|
||||
if (cancel2 == null)
|
||||
cancel2 = "<light_purple>[AllMusic]<yellow>下一首歌就是投票歌曲,已取消投票";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user