What is the difference between AudioClip and Clip in java?

折月煮酒 提交于 2019-12-08 14:40:19

问题


In my game I'm trying to add sfx and other sound elements. I used AudioClip for everything (BGM, sfx, etc). Now I would need to check if a sfx is already in loop or not. I would like to archieve that if the character is close to the portal a sfx should be played in loop. If its out of distance it should stop. I read that there is a .isRunning() function but it can be used only with Clip as far as I see. Here is a part of my code.

So what is the difference between AudioClip and Clip?

if (hero.getHeroX() > (MAZECOL - 5) * 30 && hero.getHeroY() > (MAZEROW - 4) * 30)
    if (portalSFX is not in loop)
        portalSFX.loop();
else
    portalSFX.stop();

回答1:


AudioClip belongs to the applet API. There is really no point in using it. It is older and presents limited functionality.

Clip belongs to javax.sound.sampled. It can be obtained from AudioSystem and there is an official tutorial here.



来源:https://stackoverflow.com/questions/26695530/what-is-the-difference-between-audioclip-and-clip-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!