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

发布于 2024-12-11 01:37:54 字数 1337 浏览 0 评论 0原文

我想知道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);
        }

I would like to know whether 15 mega is quite heavy applet to load?
My main problem are two sound files(.Au) that its weight is about 9 mega bytes.
Anybody has suggestion of how to use mp3 maybe instead or other ideas of reducing weight?
Thanks

Relevant code:

   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);
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟酉 2024-12-18 01:37:54

任何人都可以建议如何使用 mp3 来代替..

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

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


..将 mp3plugin.jar 添加到小程序的运行时类路径(在存档元素中)是什么意思?

<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 包中,则应以不同的方式编写该元素。


我已经下载了exe格式的MP3插件..

忽略EXE链接并下载Zip!

..我安装了它”

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

我肯定会在 HTML 中更改代码..

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

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

Add the mp3plugin.jar of the JMF to the run-time class-path of the applet (in the archive element) and Java Sound will be able to open the MP3s as though they were a wav or au.

The MP3 plugin will not be able to parse some of the more modern MP3s that do non-standard things like including cover art in the MP3, but encode them using a standard MP3 format and it will handle them OK.


..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>

Note that I also changed Archive to archive (just to keep things consistent) and

code="GUI/JPanelGameApplet.class"

(generally tolerated, but not correct) to

code="GUI.JPanelGameApplet" 

(which presumes the applet is in the GUI package). If the applet is not in the GUI package, the element should be written differently.


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

Ignore the EXE link and download the Zip!

..I installed it"

Don't bother to run/install the EXE (an EXE is no use to end users on Mac. or Unix/Linux). Just expand the Zip and add the Jar to the run-time class-path

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

That will be 'problem solved' (for the embedded applet).

不必你懂 2024-12-18 01:37:54

您可以使用 JLayer 来使用 mp3。

降低小程序大小的一种选择是单独加载音频或流式传输音频,这样您在获取音乐时至少可以有一个加载栏/图像。

You could use JLayer for using mp3's.

One option to lower your applet size is load the audio separately or stream it, that way you can at least have a loading bar/image while it's getting the music.

鹿港巷口少年归 2024-12-18 01:37:54

查看任何下载时间计算器 — 一个非常好的在线时间超过一分钟。听起来特别沉重。

Check out any download time calculator — it's more than a minute on a very good line. Sounds like extremely heavy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文