Skip to content

Unsupported conversion exception #1

@Valrog

Description

@Valrog

Greetings, I've used this project to extend the functionality of JavaFX so that it supports the playback of Ogg files. I'm using Clip to play files instead of a SourceDataLine. However, I cannot play every Ogg file and I get the following error.

IllegalArgumentException: Unsupported conversion: PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian from VORBISENC 48000.0 Hz, unknown bits per sample, mono, 1 bytes/frame, 10000.0 frames/second

Here is my play method.

public void playAudio() { 
   
        try {

            File audioFile = getAudioFile();

            if (!audioFile.exists()) {
                logger.error("No file to play!");
                return;
            }

            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(audioFile);

            if (audioInputStream == null) {
                logger.error("No file stream to play!");
                return;
            }

            AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 16000f, 16, 1, 2, 16000f, false);

            AudioInputStream convertedAudioInputStream = AudioSystem.getAudioInputStream(format, audioInputStream);

            DataLine.Info info = new DataLine.Info(Clip.class, format);

            clip = (Clip) AudioSystem.getLine(info);
            clip.addLineListener(this);
            clip.open(convertedAudioInputStream);
            this.playCompleted = false;
            clip.start();

        } catch (LineUnavailableException | UnsupportedAudioFileException | IOException ex) {
            logger.error(StackTraceHelper.getStackTrace(ex));
        } catch (Throwable ex) {
            logger.error(StackTraceHelper.getStackTrace(ex));
        }
    }

Files differ in Sample rate and Bitrate. Those who can be played have

Sample rate: 16000 Hz
Bitrate: 48 kbps

Those who cannot be played have

Sample rate: 48000 Hz
Bitrate: 80 kbps

All are encoded with Vorbis and have a Mono channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions