Compare commits
5 Commits
abd676fa49
...
95d2e41a03
Author | SHA1 | Date |
---|---|---|
|
95d2e41a03 | |
|
536743c6c1 | |
|
143f5dacda | |
|
758f6a0d48 | |
|
a901163af3 |
|
@ -105,7 +105,8 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
|
||||||
} catch (UnsupportedAudioFileException | IOException ex)
|
} catch (UnsupportedAudioFileException | IOException ex)
|
||||||
{
|
{
|
||||||
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
skipTrack();
|
currentTrack = null;
|
||||||
|
requestTrack();
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@ import com.amihaiemil.eoyaml.YamlMapping;
|
||||||
import com.amihaiemil.eoyaml.YamlSequence;
|
import com.amihaiemil.eoyaml.YamlSequence;
|
||||||
import com.amihaiemil.eoyaml.YamlSequenceBuilder;
|
import com.amihaiemil.eoyaml.YamlSequenceBuilder;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -25,6 +28,7 @@ public class Track implements Comparable<Track>
|
||||||
private String artist;
|
private String artist;
|
||||||
private final URL url;
|
private final URL url;
|
||||||
private File location = null;
|
private File location = null;
|
||||||
|
private InputStream inputStream = null;
|
||||||
private int number;
|
private int number;
|
||||||
private List<Format> formats = new ArrayList<>();
|
private List<Format> formats = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -136,6 +140,18 @@ public class Track implements Comparable<Track>
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InputStream getInputStream() throws FileNotFoundException
|
||||||
|
{
|
||||||
|
if (inputStream == null && location != null)
|
||||||
|
inputStream = new FileInputStream(location);
|
||||||
|
return inputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputStream(InputStream inputStream)
|
||||||
|
{
|
||||||
|
this.inputStream = inputStream;
|
||||||
|
}
|
||||||
|
|
||||||
void delete()
|
void delete()
|
||||||
{
|
{
|
||||||
if (location != null)
|
if (location != null)
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class TrackPlayer implements Closeable
|
||||||
|
|
||||||
private static final int DESIRED_BUFFER_SIZE = 3840 * 500;
|
private static final int DESIRED_BUFFER_SIZE = 3840 * 500;
|
||||||
private static final int MAX_READ_FAILS = 3;
|
private static final int MAX_READ_FAILS = 3;
|
||||||
private static final int RETRY_COUNT = 10;
|
private static final int RETRY_COUNT = 8;
|
||||||
private static final int RETRY_DELAY = 100;
|
private static final int RETRY_DELAY = 100;
|
||||||
|
|
||||||
private final CircularByteBuffer audioBuffer = new CircularByteBuffer(3840 * 1024);
|
private final CircularByteBuffer audioBuffer = new CircularByteBuffer(3840 * 1024);
|
||||||
|
@ -43,11 +43,11 @@ public class TrackPlayer implements Closeable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in = AudioSystem.getAudioInputStream(track.getLocation());
|
in = AudioSystem.getAudioInputStream(track.getInputStream());
|
||||||
decodedFormat = AudioSendHandler.INPUT_FORMAT;
|
decodedFormat = AudioSendHandler.INPUT_FORMAT;
|
||||||
|
|
||||||
break; // it worked!
|
break; // it worked!
|
||||||
} catch (IOException ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,7 +110,12 @@ public class TrackRequest implements Comparable<TrackRequest>
|
||||||
|
|
||||||
public URL getUrl()
|
public URL getUrl()
|
||||||
{
|
{
|
||||||
return url;
|
if (url != null)
|
||||||
|
return url;
|
||||||
|
else if (result != null)
|
||||||
|
return (result.getLink());
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(URL url)
|
public void setUrl(URL url)
|
||||||
|
|
|
@ -36,7 +36,9 @@ public class QueueCommand extends Command
|
||||||
String message = ">>> ";
|
String message = ">>> ";
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
final Track currentTrack = bot.getMusicHandler().getCurrentTrack();
|
Track currentTrack = null;
|
||||||
|
if (bot.getMusicHandler() != null)
|
||||||
|
currentTrack = bot.getMusicHandler().getCurrentTrack();
|
||||||
if (currentTrack != null)
|
if (currentTrack != null)
|
||||||
message += ":notes: **Now playing: " + currentTrack + "**\n";
|
message += ":notes: **Now playing: " + currentTrack + "**\n";
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue