java - 小程序大小(15 兆字节)太重而无法加载?

标签 java swing audio applet

我想知道15兆的小程序加载是否相当重?
我的主要问题是两个声音文件(.Au),其重量约为 9 兆字节。
有人建议如何使用 mp3 来代替或其他减肥想法吗?
谢谢

相关代码:

   public class DJ 
    {

        private ArrayList<Clip> m_Records = new ArrayList<Clip>();
        private int m_CurrentRecored = 0;
        private Thread m_MusicThread = null;
        private AppletContext m_AppletContext;
        //java.net.URL m_CodeBase;
        //AppletContext ac;

        public DJ() 
        {
            try 
            {
                createClip(getClass().getResourceAsStream("/Music/train.mp3"));
                createClip(getClass().getResourceAsStream("/Music/machine.mp3"));
            }
            catch (Exception ex)
            {
                Logger.getLogger(DJ.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

        private void createClip(java.io.InputStream i_SoundFileStream) throws Exception
        {

            InputStream i = new AudioStream(i_SoundFileStream);

            AudioInputStream sound = AudioSystem.getAudioInputStream(i);
            // load the sound into memory (a Clip)
            DataLine.Info info = new DataLine.Info(Clip.class, sound.getFormat());
            Clip clip = (Clip) AudioSystem.getLine(info);
            clip.open(sound);
            m_Records.add(clip);
        }

最佳答案

Anybody has suggestion of how to use mp3 maybe instead ..

添加mp3plugin.jar将 JMF 添加到小程序的运行时类路径(在存档元素中),Java Sound 将能够打开 MP3,就好像它们是 wav 或 au 一样。

MP3 插件将无法解析一些更现代的 MP3,这些 MP3 会执行非标准操作,例如在 MP3 中包含封面艺术,但使用标准 MP3 格式对其进行编码,并且可以正常处理它们。

<小时/>

..what did you mean to add the mp3plugin.jar to the run time class path of the applet (in the archive element)?

<HTML> 
<BODY> 
<APPLET 
    archive="MyGame.jar,mp3plugin.jar" 
    code="GUI.JPanelGameApplet" 
    width=800 
    height=580>
</APPLET> 
</P> 
</BODY> 
</HTML>

请注意,我还将 Archive 更改为 archive (只是为了保持一致)并且

code="GUI/JPanelGameApplet.class"

(通常可以容忍,但不正确)到

code="GUI.JPanelGameApplet" 

(假定小程序位于 GUI 包中)。如果小程序不在 GUI 包中,则该元素的编写方式应有所不同。

<小时/>

I've downloaded the MP3 plugin in the exe format ..

忽略 EXE 链接并下载 Zip!

..I installed it"

不必费心运行/安装 EXE(EXE 对于 Mac 或 Unix/Linux 上的最终用户来说没有用)。只需展开 Zip 并将 Jar 添加到运行时类路径

I'll definitely do that code changes in the HTML..

这将“问题解决”(对于嵌入式小程序)。

关于java - 小程序大小(15 兆字节)太重而无法加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7828708/

相关文章:

java - AttributedString的 "content"可以保存在文件中吗?

ios - AVAssetReader和AudioFileReadPackets读取音频之间的区别

android - genymotion 不发出任何声音

java - 通知不再起作用。如何修复它?

java - 我执行了dao层的mybatis update方法,但是数据库没有更新

java - 可选系统依赖性导致 "invalid, transitive dependencies (if any) will not be available"

java - 通过右键单击 JTable 中的 MySql 表删除行

java - 私有(private)方法的 Junit 测试

java - 识别用于在 Java 中显示频繁数据输入的 Swing 线程

java - 线路输入节拍检测