问题
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