Example usage for javax.sound.sampled AudioSystem NOT_SPECIFIED

List of usage examples for javax.sound.sampled AudioSystem NOT_SPECIFIED

Introduction

In this page you can find the example usage for javax.sound.sampled AudioSystem NOT_SPECIFIED.

Prototype

int NOT_SPECIFIED

To view the source code for javax.sound.sampled AudioSystem NOT_SPECIFIED.

Click Source Link

Document

An integer that stands for an unknown numeric value.

Usage

From source file:com.limegroup.gnutella.gui.mp3.BasicPlayer.java

/**
 * Sets Seek value.//  w w  w  . ja va 2s.  c  o  m
 * Linear scale : 0.0 <--> +1.0
 */
public void setSeek(double seek) throws IOException {
    double length = -1;
    if ((m_audioFileFormat != null) && (m_audioFileFormat.getByteLength() != AudioSystem.NOT_SPECIFIED))
        length = (double) m_audioFileFormat.getByteLength();
    long newPos = (long) Math.round(seek * length);
    doSeek = newPos;
}

From source file:org.apache.tika.parser.audio.AudioParser.java

public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)
        throws IOException, SAXException, TikaException {
    // AudioSystem expects the stream to support the mark feature
    if (!stream.markSupported()) {
        stream = new BufferedInputStream(stream);
    }/*from   w ww. java 2  s .c  om*/
    stream = new SkipFullyInputStream(stream);
    try {
        AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(stream);
        Type type = fileFormat.getType();
        if (type == Type.AIFC || type == Type.AIFF) {
            metadata.set(Metadata.CONTENT_TYPE, "audio/x-aiff");
        } else if (type == Type.AU || type == Type.SND) {
            metadata.set(Metadata.CONTENT_TYPE, "audio/basic");
        } else if (type == Type.WAVE) {
            metadata.set(Metadata.CONTENT_TYPE, "audio/vnd.wave");
        }

        AudioFormat audioFormat = fileFormat.getFormat();
        int channels = audioFormat.getChannels();
        if (channels != AudioSystem.NOT_SPECIFIED) {
            metadata.set("channels", String.valueOf(channels));
            // TODO: Use XMPDM.TRACKS? (see also frame rate in AudioFormat)
        }
        float rate = audioFormat.getSampleRate();
        if (rate != AudioSystem.NOT_SPECIFIED) {
            metadata.set("samplerate", String.valueOf(rate));
            metadata.set(XMPDM.AUDIO_SAMPLE_RATE, Integer.toString((int) rate));
        }
        int bits = audioFormat.getSampleSizeInBits();
        if (bits != AudioSystem.NOT_SPECIFIED) {
            metadata.set("bits", String.valueOf(bits));
            if (bits == 8) {
                metadata.set(XMPDM.AUDIO_SAMPLE_TYPE, "8Int");
            } else if (bits == 16) {
                metadata.set(XMPDM.AUDIO_SAMPLE_TYPE, "16Int");
            } else if (bits == 32) {
                metadata.set(XMPDM.AUDIO_SAMPLE_TYPE, "32Int");
            }
        }
        metadata.set("encoding", audioFormat.getEncoding().toString());

        // Javadoc suggests that some of the following properties might
        // be available, but I had no success in finding any:

        // "duration" Long playback duration of the file in microseconds
        // "author" String name of the author of this file
        // "title" String title of this file
        // "copyright" String copyright message
        // "date" Date date of the recording or release
        // "comment" String an arbitrary text

        addMetadata(metadata, fileFormat.properties());
        addMetadata(metadata, audioFormat.properties());
    } catch (UnsupportedAudioFileException e) {
        // There is no way to know whether this exception was
        // caused by the document being corrupted or by the format
        // just being unsupported. So we do nothing.
    }

    XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
    xhtml.startDocument();
    xhtml.endDocument();
}

From source file:xtrememp.tag.GenericInfo.java

@Override
public String getCodecDetails() {
    StringBuilder sb = new StringBuilder();
    sb.append("<html><b>Encoding Type: </b>");
    sb.append(getEncodingType().toUpperCase());
    sb.append("<br><b>Format: </b>").append(getFormat());
    sb.append("<br><b>Sampling rate: </b>");
    sb.append(getSampleRate()).append(" Hz");
    sb.append("<br><b>Bitrate: </b>");
    sb.append(getBitRate()).append(" Kbps");
    sb.append("<br><b>Channels: </b>");
    sb.append(getChannels());/*from w  ww  .  j  ava 2 s.c  o m*/
    if (size != AudioSystem.NOT_SPECIFIED) {
        sb.append("<br><b>Size: </b>");
        sb.append(Utilities.byteCountToDisplaySize(size));
    }
    sb.append("</html>");
    return sb.toString();
}

From source file:xtrememp.XtremeMP.java

@Override
public void acPlayPause() {
    try {//from  w w w .j  a v  a2  s  .co m
        if (playlist.isEmpty()) {
            if ((audioPlayer.getState() == AudioSystem.NOT_SPECIFIED)
                    || (audioPlayer.getState() == AudioPlayer.STOP)) {
                playlistManager.addFilesDialog(true);
            }
        } else {
            if ((audioPlayer.getState() != AudioPlayer.PLAY) && (audioPlayer.getState() != AudioPlayer.PAUSE)
                    && (playlist.getCursorPosition() == -1)) {
                playlist.begin();
            }
        }
        switch (audioPlayer.getState()) {
        case AudioPlayer.PLAY:
            audioPlayer.pause();
            break;
        case AudioPlayer.INIT:
            audioPlayer.play();
            break;
        case AudioPlayer.PAUSE:
            audioPlayer.play();
            break;
        default:
            acOpenAndPlay();
            break;
        }
    } catch (PlayerException ex) {
        logger.error(ex.getMessage());
        //                String msg = "<html><b>An exeption was generated:</b><br><br>" + ex.getMessage() + "<html>";
        //                JOptionPane.showMessageDialog(mainFrame, msg, "Error", JOptionPane.ERROR_MESSAGE);
    }
}