Adding autoflow button
This commit is contained in:
parent
d8b6db9229
commit
e7d78df2e9
@ -20,7 +20,7 @@ public class AutoFlowOff implements CommandInterface{
|
|||||||
AudioM audioM = AudioM.getInstance(null);
|
AudioM audioM = AudioM.getInstance(null);
|
||||||
try {
|
try {
|
||||||
TrackScheduler scheduler = audioM.getGuildMusicManager().scheduler;
|
TrackScheduler scheduler = audioM.getGuildMusicManager().scheduler;
|
||||||
scheduler.setAutoPlay(false);
|
scheduler.setAutoFlow(false);
|
||||||
return new ResponseEntity<>(new CommandResponseData(data.command,"ok"), HttpStatus.OK);
|
return new ResponseEntity<>(new CommandResponseData(data.command,"ok"), HttpStatus.OK);
|
||||||
} catch (NullMusicManager | NotConnectedException nullMusicManager) {
|
} catch (NullMusicManager | NotConnectedException nullMusicManager) {
|
||||||
LogManager.getLogger().catching(nullMusicManager);
|
LogManager.getLogger().catching(nullMusicManager);
|
||||||
|
@ -20,7 +20,7 @@ public class AutoFlowOn implements CommandInterface{
|
|||||||
AudioM audioM = AudioM.getInstance(null);
|
AudioM audioM = AudioM.getInstance(null);
|
||||||
try {
|
try {
|
||||||
TrackScheduler scheduler = audioM.getGuildMusicManager().scheduler;
|
TrackScheduler scheduler = audioM.getGuildMusicManager().scheduler;
|
||||||
scheduler.setAutoPlay(true);
|
scheduler.setAutoFlow(true);
|
||||||
return new ResponseEntity<>(new CommandResponseData(data.command,"ok"), HttpStatus.OK);
|
return new ResponseEntity<>(new CommandResponseData(data.command,"ok"), HttpStatus.OK);
|
||||||
} catch (NullMusicManager | NotConnectedException nullMusicManager) {
|
} catch (NullMusicManager | NotConnectedException nullMusicManager) {
|
||||||
LogManager.getLogger().catching(nullMusicManager);
|
LogManager.getLogger().catching(nullMusicManager);
|
||||||
|
@ -14,13 +14,15 @@ public class CurrentMusicData {
|
|||||||
private final long currentPos;
|
private final long currentPos;
|
||||||
private final String state;
|
private final String state;
|
||||||
private final boolean pause;
|
private final boolean pause;
|
||||||
|
private final boolean autoflow;
|
||||||
|
|
||||||
|
|
||||||
public CurrentMusicData(UserAudioTrackData info, long currentPos, String state, boolean pause) {
|
public CurrentMusicData(UserAudioTrackData info, long currentPos, String state, boolean pause, boolean autoflow) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.currentPos = currentPos;
|
this.currentPos = currentPos;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.pause = pause;
|
this.pause = pause;
|
||||||
|
this.autoflow = autoflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserAudioTrackData getInfo() {
|
public UserAudioTrackData getInfo() {
|
||||||
@ -37,4 +39,8 @@ public class CurrentMusicData {
|
|||||||
else
|
else
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAutoflow() {
|
||||||
|
return autoflow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,16 +51,16 @@ public class MusicWebAPIController {
|
|||||||
AudioTrack currentTrack = player.getPlayingTrack();
|
AudioTrack currentTrack = player.getPlayingTrack();
|
||||||
if(currentTrack == null)
|
if(currentTrack == null)
|
||||||
{
|
{
|
||||||
return new CurrentMusicData(null,0, "STOP",false);
|
return new CurrentMusicData(null,0, "STOP",false, musicCommande.audio.getGuildMusicManager().scheduler.isAutoFlow());
|
||||||
}
|
}
|
||||||
UserAudioTrackData uat = new UserAudioTrackData(musicCommande.audio.getGuildMusicManager().scheduler.getCurrentPlayingTrack());
|
UserAudioTrackData uat = new UserAudioTrackData(musicCommande.audio.getGuildMusicManager().scheduler.getCurrentPlayingTrack());
|
||||||
return new CurrentMusicData(uat, currentTrack.getPosition(), currentTrack.getState().toString(), player.isPaused());
|
return new CurrentMusicData(uat, currentTrack.getPosition(), currentTrack.getState().toString(), player.isPaused(), musicCommande.audio.getGuildMusicManager().scheduler.isAutoFlow());
|
||||||
} catch (NullMusicManager | NotConnectedException nullMusicManager) {
|
} catch (NullMusicManager | NotConnectedException nullMusicManager) {
|
||||||
return new CurrentMusicData(null,0, "STOP",false);
|
return new CurrentMusicData(null,0, "STOP",false, false);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
return new CurrentMusicData(null,0, "DISCONNECTED",false);
|
return new CurrentMusicData(null,0, "DISCONNECTED",false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,19 +2,16 @@ package net.Broken.audio;
|
|||||||
|
|
||||||
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
|
||||||
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
|
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
|
||||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
|
||||||
import net.Broken.Commands.Music;
|
|
||||||
import net.Broken.MainBot;
|
import net.Broken.MainBot;
|
||||||
import net.Broken.RestApi.Data.UserAudioTrackData;
|
import net.Broken.RestApi.Data.UserAudioTrackData;
|
||||||
import net.Broken.audio.Youtube.YoutubeTools;
|
import net.Broken.audio.Youtube.YoutubeTools;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingDeque;
|
import java.util.concurrent.BlockingDeque;
|
||||||
@ -27,7 +24,7 @@ public class TrackScheduler extends AudioEventAdapter {
|
|||||||
private final AudioPlayer player;
|
private final AudioPlayer player;
|
||||||
private final BlockingDeque<UserAudioTrack> queue;
|
private final BlockingDeque<UserAudioTrack> queue;
|
||||||
private UserAudioTrack currentPlayingTrack;
|
private UserAudioTrack currentPlayingTrack;
|
||||||
private boolean autoPlay = true;
|
private boolean autoFlow = true;
|
||||||
private ArrayList<String> history = new ArrayList<>();
|
private ArrayList<String> history = new ArrayList<>();
|
||||||
Logger logger = LogManager.getLogger();
|
Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@ -175,7 +172,7 @@ public class TrackScheduler extends AudioEventAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void needAutoPlay(){
|
private void needAutoPlay(){
|
||||||
if((queue.size() < 1) && autoPlay && currentPlayingTrack != null){
|
if((queue.size() < 1) && autoFlow && currentPlayingTrack != null){
|
||||||
logger.info("Auto add needed!");
|
logger.info("Auto add needed!");
|
||||||
AudioM audioM = AudioM.getInstance(null);
|
AudioM audioM = AudioM.getInstance(null);
|
||||||
YoutubeTools youtubeTools = YoutubeTools.getInstance(null);
|
YoutubeTools youtubeTools = YoutubeTools.getInstance(null);
|
||||||
@ -193,8 +190,12 @@ public class TrackScheduler extends AudioEventAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoPlay(boolean autoPlay) {
|
public void setAutoFlow(boolean autoFlow) {
|
||||||
this.autoPlay = autoPlay;
|
this.autoFlow = autoFlow;
|
||||||
needAutoPlay();
|
needAutoPlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAutoFlow() {
|
||||||
|
return autoFlow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ public class Authorization extends AuthorizationCodeInstalledApp {
|
|||||||
|
|
||||||
protected void notify(String url){
|
protected void notify(String url){
|
||||||
Preconditions.checkNotNull(url);
|
Preconditions.checkNotNull(url);
|
||||||
// Ask user to open in their browser using copy-paste
|
|
||||||
logger.fatal("Please open this URL: "+url);
|
logger.fatal("Please open this URL: "+url);
|
||||||
PrivateMessage.send(guild.getOwner().getUser(),"Please open this url to confirm google api account acces : " + url,null);
|
PrivateMessage.send(guild.getOwner().getUser(),"Please open this url to confirm google api account acces : " + url,null);
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ var btn_info;
|
|||||||
var btn_disconnect;
|
var btn_disconnect;
|
||||||
var btn_flush;
|
var btn_flush;
|
||||||
var btn_add;
|
var btn_add;
|
||||||
|
var switchAutoFlow;
|
||||||
var loadingFlag = false;
|
var loadingFlag = false;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -21,7 +22,7 @@ $(document).ready(function() {
|
|||||||
btn_disconnect = $('#btn_disconnect');
|
btn_disconnect = $('#btn_disconnect');
|
||||||
btn_flush = $('#flush_btn');
|
btn_flush = $('#flush_btn');
|
||||||
btn_add = $('#add_btn');
|
btn_add = $('#add_btn');
|
||||||
|
switchAutoFlow = $("#autoflow");
|
||||||
|
|
||||||
setInterval("getCurentMusic()",1000);
|
setInterval("getCurentMusic()",1000);
|
||||||
$('#modalAdd').modal();
|
$('#modalAdd').modal();
|
||||||
@ -160,6 +161,8 @@ function getCurentMusic() {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(switchAutoFlow.is(':checked') != data.autoflow)
|
||||||
|
switchAutoFlow.prop('checked', data.autoflow);
|
||||||
getPlayList();
|
getPlayList();
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -451,6 +454,15 @@ function listeners() {
|
|||||||
$('#btn_disconnect').click(function () {
|
$('#btn_disconnect').click(function () {
|
||||||
sendCommand({command : "DISCONNECT"})
|
sendCommand({command : "DISCONNECT"})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
switchAutoFlow.click(function () {
|
||||||
|
console.log(switchAutoFlow.is(':checked'))
|
||||||
|
if(switchAutoFlow.is(':checked')){
|
||||||
|
sendCommand({command: 'AUTOFLOWON'})
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sendCommand({command: 'AUTOFLOWOFF'})
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableBtn(btn) {
|
function disableBtn(btn) {
|
||||||
|
@ -174,11 +174,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th style="padding: 0px;">
|
<th style="padding: 0px;">
|
||||||
<div class="row center valign-wrapper" style="margin: 0px">
|
<div class="row center valign-wrapper" style="margin: 0px">
|
||||||
<div class="col s4 center"><h5>Playlist</h5></div>
|
<div class="col s3 center blue-grey-text text-darken-3"><h5><b>Playlist</b></h5></div>
|
||||||
<div class="col s4 center">
|
<div class="col s3 center">
|
||||||
<a class="waves-effect waves-light btn modal-trigger red darken-4" id="flush_btn"><i class="material-icons">delete_sweep</i></a>
|
<a class="waves-effect waves-light btn modal-trigger red darken-4" id="flush_btn"><i class="material-icons">delete_sweep</i></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s4 center">
|
<div class="col s3 center" style="padding-right: 0px">
|
||||||
<!-- Modal Trigger -->
|
<!-- Modal Trigger -->
|
||||||
<a class="waves-effect waves-light btn modal-trigger green darken-4" id="add_btn" href="#modalAdd"><i class="material-icons">add_circle_outline</i></a>
|
<a class="waves-effect waves-light btn modal-trigger green darken-4" id="add_btn" href="#modalAdd"><i class="material-icons">add_circle_outline</i></a>
|
||||||
|
|
||||||
@ -215,6 +215,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col s3 center " style="padding-left: 0px">
|
||||||
|
<div class="row switch blue-grey-text text-darken-3" style="margin-bottom: 0px">
|
||||||
|
AutoFlow
|
||||||
|
</div>
|
||||||
|
<div class="row switch ">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="autoflow"/>
|
||||||
|
<span class="lever"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
|
Loading…
Reference in New Issue
Block a user