Question

I poked around the internet a bit but had no luck. Does anyone know if one exists?

Était-ce utile?

La solution

Apparently the answer is no. Haven't been able to find anything out there.

Autres conseils

Use Quicktime API for doing such a thing,

i have solved my problem using this quickTime.jar

you can download this utility from apple.com.

I realize you're looking for a .jar file to just drop in and provide support for .wma files, but this solution was how I got support for .wma files and it wasn't much more complicated than dropping in a new jar. This isn't technically an SPI, but since there seem to be no such thing I thought a simple alternative might be useful to have posted.

From this answer I found my direction. Before you dive in to JAVE and see what it's about, though, I'll provide a length of code so you can see about how much I had to write to get a wma file converted and playing. Everything JAVE does requires you to use an instance of the Encoder class.

try {
    EncodingAttributes attr = new EncodingAttributes();
    attr.setAudioAttributes(new AudioAttributes()); //default values
    attr.setVideoAttributes(new VideoAttributes()); //default values
    attr.setFormat("wav"); //this is the target format I am trying to achieve
    //b.wma is a file I brought to the project
    File wma = new File("Resources\\b.wma");
    //target.wav is the created file I'll achieve after the encode, which gets used to  make a Clip
    File target = new File("Resources\\target.wav");
    Encoder encoder = new Encoder();
    //this will show you all supported encoding / decoding formats
    //String[] list = encoder.getSupportedEncodingFormats();
    //String[] list = encoder.getSupportedDecodingFormats()
    encoder.encode(wma, target, attr);
    AudioInputStream is = AudioSystem.getAudioInputStream(target);
    Clip clip = AudioSystem.getClip();
    clip.open(is);
    clip.setFramePosition(0);
    clip.start();

} catch (IllegalArgumentException | EncoderException e) {
    e.printStackTrace();
} catch (UnsupportedAudioFileException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
} catch (LineUnavailableException e) {
    e.printStackTrace();
}

If you're on Windows 7 or later, you might want to try MFSampledSP.

If you're adventurous and need to support other platforms than Windows, you could try modifying FFSampledSP and its upstream project.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top