⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseaudio.java

📁 一个java的免费游戏引擎,里面有文档,和例子
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

package com.golden.gamedev.engine;

import com.golden.gamedev.util.Utility;

// Referenced classes of package com.golden.gamedev.engine:
//            BaseAudioRenderer, BaseIO

public class BaseAudio
    implements Runnable
{

    public static final int SINGLE;
    public static final int MULTIPLE = 1;
    public static final int SINGLE_REPLAY = 2;
    private int d;
    private int e;
    private BaseAudioRenderer f;
    private BaseAudioRenderer g[];
    private String h[];
    private String i;
    private BaseIO j;
    private boolean k;
    private boolean l;
    private float m;
    private boolean n;
    private int o;

    public BaseAudio(BaseIO baseio, BaseAudioRenderer baseaudiorenderer)
    {
        d = 1;
        j = baseio;
        f = baseaudiorenderer;
        n = baseaudiorenderer.isAvailable();
        m = 1.0F;
        o = 10;
        e = 6;
        g = new BaseAudioRenderer[0];
        h = new String[0];
        Thread thread;
        (thread = new Thread(this)).setDaemon(true);
        thread.start();
    }

    public void run()
    {
        do
        {
            try
            {
                Thread.sleep(100L);
            }
            catch(InterruptedException _ex) { }
            for(int i1 = 0; i1 < g.length; i1++)
                if(g[i1].isLoop() && g[i1].getStatus() == 3)
                    g[i1].play();

        } while(true);
    }

    public int play(String s)
    {
        return play(s, d);
    }

    public int play(String s, int i1)
    {
        i = s;
        if(!n)
            return -1;
        int j1 = g.length > o ? -2 : -1;
        int k1 = 0;
        for(int l1 = 0; l1 < g.length; l1++)
        {
            if(h[l1].equals(s))
            {
                if(g[l1].getStatus() == 1)
                    k1++;
                if(i1 == 1 && !k)
                {
                    if(g[l1].getStatus() != 1)
                    {
                        g[l1].setVolume(m);
                        g[l1].play();
                        return l1;
                    }
                } else
                {
                    if(i1 == 2)
                    {
                        if(k)
                            stopAll();
                        else
                            g[l1].stop();
                        g[l1].setVolume(m);
                        g[l1].play();
                        return l1;
                    }
                    if(k)
                        stopAll(g[l1]);
                    if(g[l1].getStatus() != 1)
                    {
                        g[l1].setVolume(m);
                        g[l1].play();
                    }
                    return l1;
                }
            }
            if(j1 == -2 && g[l1].getStatus() != 1)
                j1 = l1;
        }

        if(k1 >= e)
            return -1;
        if(j1 < 0)
        {
            g = (BaseAudioRenderer[])Utility.expand(g, 1);
            h = (String[])Utility.expand(h, 1);
            j1 = g.length - 1;
        }
        if(g[j1] == null)
        {
            g[j1] = createRenderer();
            g[j1].setLoop(l);
        }
        if(k)
            stopAll();
        else
            stop(j1);
        g[j1].setVolume(m);
        g[j1].play(j.getURL(s));
        h[j1] = s;
        return j1;
    }

    public void stop(int i1)
    {
        if(g[i1].getStatus() == 1)
            g[i1].stop();
    }

    public void stop(String s)
    {
        BaseAudioRenderer baseaudiorenderer;
        if((baseaudiorenderer = getAudioRenderer(s)) != null)
            baseaudiorenderer.stop();
    }

    public void stopAll()
    {
        int i1 = g.length;
        for(int j1 = 0; j1 < i1; j1++)
            stop(j1);

    }

    public void stopAll(BaseAudioRenderer baseaudiorenderer)
    {
        int i1 = g.length;
        for(int j1 = 0; j1 < i1; j1++)
            if(g[j1] != baseaudiorenderer)
                stop(j1);

    }

    public BaseAudioRenderer getAudioRenderer(int i1)
    {
        return g[i1];
    }

    public BaseAudioRenderer getAudioRenderer(String s)
    {
        int i1 = g.length;
        for(int j1 = 0; j1 < i1; j1++)
            if(h[j1].equals(s))
                return g[j1];

        return null;
    }

    public String getLastAudioFile()
    {
        return i;
    }

    public BaseAudioRenderer[] getRenderers()
    {
        return g;
    }

    public int getCountRenderers()
    {
        return g.length;
    }

    public float getVolume()
    {
        return m;
    }

    public void setVolume(float f1)
    {
        if(f.isVolumeSupported() && m != f1)
        {
            m = f1;
            int i1 = g.length;
            for(int j1 = 0; j1 < i1; j1++)
                g[j1].setVolume(f1);

        }
    }

    public int getAudioPolicy()
    {
        return d;
    }

    public void setAudioPolicy(int i1)
    {
        d = i1;
    }

    public int getMaxSimultaneous()
    {
        return e;
    }

    public void setMaxSimultaneous(int i1)
    {
        e = i1;
    }

    public boolean isExclusive()
    {
        return k;
    }

    public void setExclusive(boolean flag)
    {
        k = flag;
        if(flag)
            stopAll();
    }

    public int getBuffer()
    {
        return o;
    }

    public void setBuffer(int i1)
    {
        o = i1;
    }

    public boolean isLoop()
    {
        return l;
    }

    public void setLoop(boolean flag)
    {
        if(l != flag)
        {
            l = flag;
            int i1 = g.length;
            for(int j1 = 0; j1 < i1; j1++)
                g[j1].setLoop(flag);

        }
    }

    public BaseIO getBaseIO()
    {
        return j;
    }

    public void setBaseIO(BaseIO baseio)
    {
        j = baseio;
    }

    public boolean isActive()
    {
        return n;
    }

    public void setActive(boolean flag)
    {
        n = isAvailable() ? flag : false;
        if(!n)
            stopAll();
    }

    public boolean isAvailable()
    {
        return f.isAvailable();
    }

    public BaseAudioRenderer getBaseRenderer()
    {
        return f;
    }

    public void setBaseRenderer(BaseAudioRenderer baseaudiorenderer)
    {
        f = baseaudiorenderer;
        if(n)
            n = f.isAvailable();
    }

    protected BaseAudioRenderer createRenderer()
    {
        return (BaseAudioRenderer)Class.forName(f.getClass().getName()).newInstance();
        Exception exception;
        exception;
        throw new RuntimeException("Unable to create new instance of audio renderer on " + this + " audio manager caused by: " + exception.getMessage() + "\n" + "Make sure the base renderer has one empty constructor!");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -