I am storaging mp3 files in google cloud stoarge and I want to get the durations of the files. I've tried to do this but it is not working somehow:
ListResult lr = gcsService.list(mybucketname, ListOptions.DEFAULT);
while (lr.hasNext() && playlistLength > 0) {
ListItem li = lr.next();
String filename = "/gs/mybucketname/" + li.getName();
AppEngineFile readableFile = new AppEngineFile(filename);
String st = readableFile.getFullPath();
File file = new File(st);
AudioInputStream audioInputStream = null;
try {
audioInputStream = AudioSystem.getAudioInputStream(file);
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
}
AudioFormat format = audioInputStream.getFormat();
long frames = audioInputStream.getFrameLength();
double durationInSeconds = (frames+0.0) / format.getFrameRate();
playlistLength-=(int)(durationInSeconds)/60;
}
}