Add support for Tracks to store new input stream formats, not just files.
This commit is contained in:
parent
536743c6c1
commit
95d2e41a03
|
@ -10,6 +10,9 @@ import com.amihaiemil.eoyaml.YamlMapping;
|
|||
import com.amihaiemil.eoyaml.YamlSequence;
|
||||
import com.amihaiemil.eoyaml.YamlSequenceBuilder;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
@ -25,6 +28,7 @@ public class Track implements Comparable<Track>
|
|||
private String artist;
|
||||
private final URL url;
|
||||
private File location = null;
|
||||
private InputStream inputStream = null;
|
||||
private int number;
|
||||
private List<Format> formats = new ArrayList<>();
|
||||
|
||||
|
@ -136,6 +140,18 @@ public class Track implements Comparable<Track>
|
|||
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()
|
||||
{
|
||||
if (location != null)
|
||||
|
|
|
@ -43,7 +43,7 @@ public class TrackPlayer implements Closeable
|
|||
{
|
||||
try
|
||||
{
|
||||
in = AudioSystem.getAudioInputStream(track.getLocation());
|
||||
in = AudioSystem.getAudioInputStream(track.getInputStream());
|
||||
decodedFormat = AudioSendHandler.INPUT_FORMAT;
|
||||
|
||||
break; // it worked!
|
||||
|
|
Loading…
Reference in New Issue