Applet的大小(15兆字节)过重加载? [英] Applet size (15 megabytes) too heavy to load?

查看:99
本文介绍了Applet的大小(15兆字节)过重加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

相关code:

 公共类DJ
    {        私人的ArrayList<剪辑GT; m_Records =新的ArrayList<夹>();
        私人INT m_CurrentRecored = 0;
        私人主题m_MusicThread = NULL;
        私人AppletContext m_AppletContext;
        //java.net.URL M_ codeBase的;
        // AppletContext交流;        公共DJ()
        {
            尝试
            {
                createClip(的getClass()的getResourceAsStream(/音乐/ train.mp3));
                createClip(的getClass()的getResourceAsStream(/音乐/ machine.mp3));
            }
            赶上(异常前)
            {
                。Logger.getLogger(DJ.class.getName())日志(Level.SEVERE,空,前);
            }        }        私人无效createClip(java.io.InputStream中i_SoundFileStream)抛出异常
        {            我的InputStream =新语音串流(i_SoundFileStream);            的AudioInputStream声音= AudioSystem.getAudioInputStream(ⅰ);
            //加载声音到内存(剪辑)
            DataLine.Info信息=新DataLine.Info(Clip.class,sound.getFormat());
            夹夹=(剪辑)AudioSystem.getLine(信息);
            clip.open(音);
            m_Records.add(剪辑);
        }


解决方案

  

任何人有关于如何使用MP3也许反而建议。


在JMF中添加 mp3plugin.jar 到运行时小程序的类路径(存档元素)和Java声音就可以打开MP3音乐,好像他们是一个wav或Au。

在MP3插件将无法使用标准的MP3格式解析一些更现代的MP3是做非标之类的东西,包括在MP3封面,但恩code他们会处理它们OK



  

..那你的意思是到mp3plugin.jar添加到小程序的运行时类路径(在归档元素)?


 < HTML>
< BODY>
< APPLET
    归档=MyGame.jar,mp3plugin.jar
    code =GUI.JPanelGameApplet
    宽度= 800
    高度= 580>
< / APPLET>
&所述; /差异无显着
< / BODY>
< / HTML>

请注意,我也改变了存档归档(只是为了保持一致),以及

  code =GUI / JPanelGameApplet.class

(通常是允许的,但不正确),以

  code =GUI.JPanelGameApplet

(其中presumes小程序是在 GUI 封装)。如果小程序的不可以在GUI包中,该元素应该以不同的写入。



  

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


忽略EXE链接,下载zip!


  

..我安装了


不要刻意去运行/安装EXE(一个EXE是没有用的,结束在Mac上。或Unix / Linux用户)。只需展开邮编和JAR添加到运行时类路径


  

我肯定会做在code的变化.. HTML


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

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

解决方案

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

这篇关于Applet的大小(15兆字节)过重加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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