improve audioparser
@@ -32,7 +32,9 @@ import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
+import org.apache.commons.io.IOUtils;
import org.apache.tika.exception.TikaException;
+import org.apache.tika.io.ProxyInputStream;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.XMPDM;
import org.apache.tika.mime.MediaType;
@@ -66,6 +68,7 @@ public class AudioParser extends AbstractParser {
if (!stream.markSupported()) {
stream = new BufferedInputStream(stream);
}
+ stream = new SkipFullyInputStream(stream);
try {
AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(stream);
Type type = fileFormat.getType();
@@ -137,4 +140,17 @@ public class AudioParser extends AbstractParser {
}
}
+ private static class SkipFullyInputStream extends ProxyInputStream {
+
+ public SkipFullyInputStream(InputStream proxy) {
+ super(proxy);
+ }
+
+ @Override
+ public long skip(long ln) throws IOException {
+ IOUtils.skipFully(in, ln);
+ return ln;
+ }
+ }
+
}
