- try {
- Format format = OggVorbisIdentifier.identify(rememberingInputStream);
- return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), format));
- } catch (IdentifierException ie1) {
- rememberingInputStream = new RememberingInputStream(rememberingInputStream.remembered());
+ Optional<Format> format = OggVorbisIdentifier.identify(rememberingInputStream);
+ if (format.isPresent()) {
+ return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), format.get()));
+ }
+
+ /* try MP3 now. */
+ rememberingInputStream = new RememberingInputStream(rememberingInputStream.remembered());
+ InputStream limitedInputStream = ByteStreams.limit(rememberingInputStream, 1048576);
+ format = Mp3Identifier.identify(limitedInputStream);
+ if (format.isPresent()) {
+ return Optional.of(new IdentifyingInputStream(rememberingInputStream.remembered(), format.get()));