TrackData trackData = track.getTrackData();
try {
this.track = track;
if (trackData.isFile()) {
logger.fine("Opening file: " + trackData.getFile());
vorbisFile = new VorbisFile(trackData.getFile().getAbsolutePath());
streaming = false;
oldBitrate = trackData.getBitrate();
} else if (trackData.isStream()) {
URL url = trackData.getLocation().toURL();
logger.fine("Opening stream: " + URLDecoder.decode(url.toString(), "utf8"));
URLConnection urlConnection = url.openConnection();
String contentType = urlConnection.getContentType();
if (!contentType.equals("application/ogg")) {
logger.warning("Wrong content type: " + contentType);
return false;
}
InputStream is = urlConnection.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
vorbisFile = new VorbisFile(bis, null, 0);
streaming = true;
reloadComments(track);
trackData.setCodec("OGG Vorbis Stream");
}
Info info = vorbisFile.getInfo()[0];