Example usage for javax.sound.sampled AudioFileFormat toString

List of usage examples for javax.sound.sampled AudioFileFormat toString

Introduction

In this page you can find the example usage for javax.sound.sampled AudioFileFormat toString.

Prototype

@Override
public String toString() 

Source Link

Document

Provides a string representation of the file format.

Usage

From source file:uk.co.modularaudio.service.audiofileioregistry.impl.AudioFileIORegistryServiceImpl.java

@Override
public AudioFileFormat sniffFileFormatOfFile(final String path)
        throws DatastoreException, RecordNotFoundException, UnsupportedAudioFileException {
    AudioFileFormat retVal = AudioFileFormat.UNKNOWN;

    for (final AudioFileIOService oneService : services) {
        try {/* w w w.  j a  va  2  s .c  o  m*/
            final AudioFileFormat foundFormat = oneService.sniffFileFormatOfFile(path);
            retVal = foundFormat;
            if (retVal != AudioFileFormat.UNKNOWN) {
                if (log.isTraceEnabled()) {
                    log.trace("Service \"" + oneService.getClass().getSimpleName() + "\" recognised format as "
                            + foundFormat.toString());
                }
                return retVal;
            }
        } catch (final RecordNotFoundException rnfe) {
            if (log.isTraceEnabled()) {
                log.trace("Service \"" + oneService.getClass().getSimpleName() + "\" threw rnfe for file "
                        + path);
            }
        } catch (final UnsupportedAudioFileException uafe) {
            if (log.isTraceEnabled()) {
                log.trace("Service \"" + oneService.getClass().getSimpleName() + "\" threw uafe for file "
                        + path);
            }
        }
    }
    if (retVal == AudioFileFormat.UNKNOWN) {
        throw new UnsupportedAudioFileException("Could not determine type of file \"" + path + "\"");
    }
    return retVal;
}