解决方法UnsupportedAudioFileException? [英] Workaround for UnsupportedAudioFileException?

查看:295
本文介绍了解决方法UnsupportedAudioFileException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用Java编写的小音乐/节奏游戏的一个非常早期的阶段(通过油滑框架,轮流使用OpenAL的,但是这可能无关紧要这里)。本场比赛需要读取WAV格式(和播放)几个声音文件,但一些文件被扔[javax.sound.sampled.UnsupportedAudioFileException]例外。

I'm in a very early stage of writing a small music/rhythm game in Java (via Slick framework, which in turns uses OpenAL, but that's probably irrelevant here). The game needs to read (and playback) several sound files in WAV format, but some of the files are throwing [javax.sound.sampled.UnsupportedAudioFileException] exceptions.

at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1102)
at org.newdawn.slick.openal.WaveData.create(WaveData.java:123)
at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:713)
at org.newdawn.slick.openal.SoundStore.getWAV(SoundStore.java:683)
at org.newdawn.slick.Sound.<init>(Sound.java:33)

该文件可在Winamp或Foobar2000的回放就好了,所以这意味着Java的只是不承认文件格式的一些变种。什么是我在这一点上的选择吗?

The files can be played back just fine in Winamp or Foobar2000, so this means Java just don't recognize some variants of the file format. What are my options at this point?

请注意:有问题的文件是用户提供的,所以我不能只是将它们转换事前(使用类似的勇气)。任何转换步骤必须在运行时完成。

Note: The files in question are user-supplied, so i cannot just convert them beforehand (using something like audacity). Any conversion steps must be done at runtime.

推荐答案

有一件事情需要认识到了解 WAV 的文件是,是,它是一个容器格式 - 它可以在许多不同的格式保存数据,包括 uncom pressed PCM MP3

One thing that needs to be recognized about WAV files are, is that it is a container format -- it can hold data in many different formats, including uncompressed PCM to MP3.

在这种情况下,我会猜测,正在使用该库钩住 Java的声音API 和API的实现不支持包含在 WAV 文件中的数据的格式,导致<一个href=\"http://java.sun.com/javase/6/docs/api/javax/sound/sampled/UnsupportedAudioFileException.html\"><$c$c>UnsupportedAudioFileException例外。

In this case, I am going to guess that the library that is being used is hooking into the Java Sound API, and the implementation of the API does not support the format of the data contained in the WAV file, leading to an UnsupportedAudioFileException exception.

该文件可以播放回来就好
  在Winamp或Foobar2000的,所以这意味着
  Java的只是不承认一些
  文件格式的变体。

The files can be played back just fine in Winamp or Foobar2000, so this means Java just don't recognize some variants of the file format.

为什么AOL的Winamp和其他程序可以回放 WAV 文件的原因是因为它很可能使用的是Windows的音频的COM pression经理或(如果我理解正确)的DirectShow ,这是用来管理不同类型的音频codeCS 的。

The reason why Winamp and other programs can playback the WAV file is because it is probably using the Windows Audio Compression Manager or (if I understand correctly) DirectShow, which is used to manage different types of audio codecs.

Winamp的本身并不需要知道如何反code中的 WAV 文件中的音频数据;它要求ACM或DirectShow来回报它可以处理的原始音频数据。 (或者也可能是,该数据被直接发送到音频输出)。

Winamp itself does not need to know how to decode the audio data inside the WAV file; it asks ACM or DirectShow to return the raw audio data on which it can handle. (Or also possibly, the data is directly send to the audio output.)

什么是我在这一点上的选择吗?

What are my options at this point?

这是另一种似乎在 Java媒体框架的形式,存在哪些似乎有支持多种多媒体格式

An alternative does seem to exist in the form of the Java Media Framework, which appears to have support many multimedia formats.

它说,使用JMF 2.1.1 Windows性能包时,它会勾到Windows ACM,所以它可能是能够播放的 WAV 文件,这不能由在Java声音API进行回放。

It says that it will hook into the Windows ACM when using the "JMF 2.1.1 Windows Performance Pack", so it might be able to playback the WAV files which can't be played back by the Java Sound API.

这篇关于解决方法UnsupportedAudioFileException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆