Is this bad usage of the applet sound player

I have this class for playing audio for my application.
currently it is a game the is presented in a JFrame but when trying to play audio i kept coming across the use of java.applet.AudioClip for playing audio.
what i want to know is what i am doing really bad use of this class?
and if so where should i look to find tips on how to make a better audio class for my game?
import java.applet.AudioClip;
import java.applet.Applet;
public class SoundPlayer {
     public static final int WALL_HIT_SOUND = 1,  BRICK_HIT_SOUND = 2,  POWER_UP_SOUND = 3;
     private static boolean setUp = false;
     private static AudioClip wallHit = null,  brickHit = null,  powerUp = null;
     public void play(int clipID) {
          if (!setUp) {
               setUp();
          AudioClip clip;
          switch (clipID) {
               default:
               case WALL_HIT_SOUND:
                    clip = wallHit;
                    break;
               case BRICK_HIT_SOUND:
                    clip = brickHit;
                    break;
               case POWER_UP_SOUND:
                    clip = powerUp;
                    break;
          if (clip != null) {
               clip.play();
     public void setUp() {
          wallHit = loadClip("wallHit");
          brickHit = loadClip("brickHit");
          powerUp = loadClip("powerUp");
          setUp = true;
     public AudioClip loadClip(String name) {
          try {
               return Applet.newAudioClip(getClass().getResource("/sound/files/" + name + ".wav"));
          } catch (Exception e) {
               System.err.println("Cannot open Audio File: " + name + ".wav will not play this sound");
               return null;
}Thanks Scott.

To respond to your first question (Is it bad to use)
java.applet.AudioClip isn't part of the JavaSound API, so this isn't really the correct forum to ask this question.
You should go check out a generic applet forum for the question...
To respond to your second question (What should I use if it's bad)
javax.sound.sampled.Clip is probably what you should be using for an application to play short sounds.
/*  To load a clip */
AudioInputStream ais = AudioSystem.getAudioInputStream(new File("bang.wav"));
Clip c = AudioSystem.getClip();
c.open(ais);
/* To play a clip */
c.start();
/* To stop */
c.stop();
/* To stop & reset to beginning */
c.stop();
c.setFramePosition(0);

Similar Messages

  • I continuously get a Firefox pop-up saying that there are missing plug-ins. This seems to be the Adobe Flash Player and the installation fails when I click on the button. I've installed it manually but Firefox still gives the pop-up. Very frustrating.

    Pop-up is the yellow bar at the top with the Install Plugin button enabled

    Flash Player is free, and you might ask for help in Flash Player
    This forum is about the Cloud as a delivery process, not about using individual programs... and as far as I know, Flash Player is a different, free, download
    If you start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • Virus scan failed Error on deploying a web application having a jar file for calling the applet on the jsp page

    Hi,
    I have an applet application that i want to deploy on the Oracle cloud.
    So i have created a jar file for the applet application and i am using this jar to call the applet on a jsp page.
    But when i am delpoying my application on the java cloud, its giving me the below error:
    2014-10-28 03:16:41 CDT: Starting action "Virus Scan"
    2014-10-28 03:16:41 CDT: Virus Scan started
    2014-10-28 03:16:49 CDT: ----------------------------------------------------------------------
    2014-10-28 03:16:49 CDT: File Scanned: "Application7.ear".
    2014-10-28 03:16:49 CDT: File Size: "106698122".
    2014-10-28 03:16:49 CDT: File Status: "INFECTED".
    2014-10-28 03:16:49 CDT: ----------------------------------------------------------------------
    2014-10-28 03:16:49 CDT: Virus scan failed.
    2014-10-28 03:16:49 CDT: "Virus Scan" complete: status FAILED
    Can't we deploy any application having applet or swing component's onto the cloud?
    Or do we need to request for any extra permissions for the same?
    Thanks,
    Manoj

    I don't see applets mentioned in the supported features nor in the unsupported features so not sure if they are supported you would likely need to contact the operations team to confirm.
    Jani Rautiainen
    Fusion Applications Developer Relations
    https://blogs.oracle.com/fadevrel/

  • User Exit / BAdI to update the pricing conditions of the Purchase Order

    Hello SAPients,
    This is my requirement:
    "Copy the Pricing Conditions from the Shipment Cost Document (VI01 / VI02) to the automatically generated Purchase Order".
    I'm using the enhancement V54U0002 (Function Module EXIT_SAPLV54U_002) to EXPORT  the values of the Pricing Conditions to memory and I have used the enhancement MM06E005 ( FM EXIT_SAPMM06E_006, 007, 012, 013, 014, 016, and 017) to IMPORT the values from memory and store them in TKOMV. But, when the PO is generated the values don't stay, they are always changed with the standard PBXX pricing conditions.
    My question is: Does anyone know the User Exit / BAdI that I can use to change the Pricing Conditions of the Purchase Order?
    <<removed_by_moderator>>
    Thanks!
    Edited by: Vijay Babu Dudla on Jan 14, 2009 11:08 PM

    >
    kartik tarla wrote:
    > check this badi
    > ME_PROCESS_PO_CUST
    >
    > and the following user exit
    > Goto-> include RV61AFZA then search for
    > USEREXIT_PRICING_RULE see if its helpful to u.
    Hello Kartik / SAPients,
    I tried with ME_PROCESS_PO_CUST but didn't work. The system doesn't execute that code. Any other idea would be greatly appreciated.
    Thanks.

  • How can I shut down the start sound on my IMac under OS X 10.9.5

    How can I shut down the start sound on my IMac under OS X 10.9.5

    Did you try using 'mute' in the System Preferences> Sound> output>
    control panel? This usually will mute the startup sound; you may have
    to try a few things to be sure only the startup will mute, not all sounds.
    Of course, you could likely write an apple script in automator or in
    text edit, that could automatically mute before shutdown and then
    in startup items, have the script un-mute the audio for everything.
    There are possibilities that do not include the command line; but
    if you learn how to use that, without messing up other functions,
    then even more custom control is possible in Mac OS X.
    With that, you could write a substitute 'sound file' with white noise
    or nothing in there; so instead of Bong, it'd be as quiet as a mouse.
    PS: You may have a local reason why the site link posted above
    does not work for you, but it does function and if the product is
    free to use, and does not include adware or malware, here is an
    untested download link from their site. (I can go there, easily.)
    http://www.allvu.com/index.php/sndownloadpage.html
    and note:
    http://www.allvu.com/downloads/StartNinjaInstaller.dmg is the
    actual DL link for this product. Mouse over the buttons to see it.
    (The other downloads are highly suspect; even this one is to me)
    There may be a reason in your Mac OS X 10.9.x for gatekeeper
    to not allow odd download installations, there is a way around
    that feature, but I do not recommend using unknown software.
    In any event...
    Good luck & happy computing!
    edited 2x

  • Refresh the applet !!!!!!

    We developed an internationalizated applet with jdk1.3.0 and we used hide and show functions
    to repaint the applet and obtain the applet with the new language selected.
    Now in Swing with jdk1.3.1 hide and show are deprecated and the setVisible doesn't do the same.
    We have tried some options, here you have the code of the function that realizes the change of
    the idiom:
    private void canviIdioma( String str )
    if( str.equals( "Angl?s" ) )
    language = new String( "en" );
    country = new String( "US" );
    if(str.equals( "Catal?" ))
    language = new String( "ca" );
    country = new String( "CA" );
    currentLocale = new Locale( language,country );
    missatges = ResourceBundle.getBundle( "ResourceBundle",currentLocale );
    myCollator=Collator.getInstance( currentLocale );
    repaint();
    System.out.println(missatges.getString("titol1"));
    // getContentPane().invalidate();
    // getContentPane().validate();
    // setVisible(false); //hide
    // setVisible(true); //show
    // hide();
    // show();
    // invalidate();
    // repaint();
    // revalidate();
    // getContentPane().revalidate();
    // doLayout();
    // setVisible(true);
    The change of the idiom is done correctly because the System.out.println writes the correct string.
    What must we do to repaint ?
    Thanks

    The only thing which comes to my mind now is that you are not specifying what to repaint.
    If the applet is in the same class, try
    this.repaint();
    If you the applet in a different class like
    class hello extends applet
    //code
    then you can call
    hello.repaint();

  • The applet

    Hi. A question about the applet....
    I'm using the follow parameter in the formsweb.cfg file to open my applications in an IE window that won't have all the user's Internet Explorer toolbars and push buttons. My intent is to maximize the amount of canvas displayed during runtime:
    # Forms applet parameter
    separateFrame=true
    A follow up concern about using this setting is that the applet first opens in an separate IE window and remains open even after my application's IE window is closed by the user.
    For our non-technical users here on my project this will likely be confusing. Is there anyway to sync the closing of the applet window along with the closing of my separate application IE window?
    Or better yet - Is there a way to keep the applet IE window running for the user, but in a mode that is minimized or even invisible to the user?
    Any advice would be appreciated. Thanks in advance.

    it can't close itself. You have to manually close it e.g. in your post-form-trigger of your main form.
    then you start some java-script, which closes the window. Many examples of statement can be found in this forum, if you explicitly search for it.

  • I have Adobe premiere 12 elements I have Buy it but this program is Corrupt. the are no sound on the time line. I have sound in my computer, this is no problem, I can listen every another things but NO Elements 12 OK I make ia video take down to the time

    i have Adobe premiere 12 elements I have Buy it but this program is Corrupt. the are no sound on the time line. I have sound in my computer, this is no problem, I can listen every another things but NO Elements 12 OK I make ia video take down to the time line. Video is OK BUT NO sound I have makit in 2 veeks from monday to next vek here whit this very bad program so i go to garbags I think I buy a another program is be better and have a Sound. This is very bad I am not god to English. I Have a pro camera and I will have a god support but this is very bad. I is bad to English. But this Program I buy i think this is very Corrupt. The mast find a sound in this program. I cvan not understan if You can sell this very bad program Videoredigering and this program have nothing sound. This is crazy.

    i have Adobe premiere 12 elements I have Buy it but this program is Corrupt. the are no sound on the time line. I have sound in my computer, this is no problem, I can listen every another things but NO Elements 12 OK I make ia video take down to the time line. Video is OK BUT NO sound I have makit in 2 veeks from monday to next vek here whit this very bad program so i go to garbags I think I buy a another program is be better and have a Sound. This is very bad I am not god to English. I Have a pro camera and I will have a god support but this is very bad. I is bad to English. But this Program I buy i think this is very Corrupt. The mast find a sound in this program. I cvan not understan if You can sell this very bad program Videoredigering and this program have nothing sound. This is crazy.

  • Sound goes off, goes bad then effects the PC

    I'm a tumblr user and I spend most of my time there on my computer. Recently videos sounds started to go off after a few loops. Then it completely goes off or goes bad like the audio damaged terribly. Even the system slows down. When I checked other sites their sounds are bad too and even chrome or something I listen from winamp gets effected. I checked my sound settings and try to test the sound then I got an error messege saying "Failed to play test tone". It gets normal after restart.
    So I thought it's hopeless and I was even thinking of formatting my pc. But when I used chrome all day I didn't encounter this problem at all.

    Some problems with Flash video playback can be resolved by disabling hardware acceleration in your Flash Player settings. (See [[Flash Plugin - Keep it up to date and troubleshoot problems|this article]] for more information on using the Flash plugin in Firefox).
    To disable hardware acceleration in Flash Player:
    #Go to this [http://helpx.adobe.com/flash-player/kb/video-playback-issues.html#main_Solve_video_playback_issues Adobe Flash Player Help page].
    #Right-click on the Flash Player logo on that page.
    #Click on '''Settings''' in the context menu. The Adobe Flash Player Settings screen will open.
    # Click on the icon at the bottom-left of the Adobe Flash Player Settings window to open the Display panel. <br/> <br/>[[Image:fpSettings1.PNG]] <br/>
    # Remove the check mark from '''Enable hardware acceleration'''.
    # Click '''Close''' to close the Adobe Flash Player Settings Window.
    # Restart Firefox.
    This [http://www.macromedia.com/support/documentation/en/flashplayer/help/help01.html Flash Player Help - Display Settings page] has more information on Flash Player hardware acceleration, if you're interested.
    Does this solve the problem? Let us know.

  • PCI-5114 clicks when the trigger is changed---is this bad?

    Hi everyone,
    I'm working with a PCI-5114, using several triggers in a LabVIEW program that loops every second.  In the program, I first trigger off of channel 0, then I reset the trigger to collect different information, this time triggering off of the trigger channel, and reading out channel 1.  This works, and I get the data that I want (hooray!), but every time the trigger changes (once per second), I hear a loud click from the PCI-5114.  Is this bad?  Will switching like this eventually harm my digitizer? 
    If it's not bad, I'm happy to endure the clicking.  If it is bad, then I need to figure out a new way to read out my card.  
    Thanks in advance!
    Solved!
    Go to Solution.

    Hello Karl,
    Some scope cards, such as the PCI-5114, have active switches in them.  The noise you are hearing is the switching anytime you change your analog trigger from one channel to another.  These switches will eventually go bad after extended usage, so I highly recommend that you stop switching the analog trigger back and forth each iteration of your loop.  Once the switch goes bad, your card will have to be sent in for repair.  Instead, you may want to look into using one of the PFI lines as a trigger instead.  
    Regards,

  • My Ipad 2 external speakers does not work and headphones has popping sound. This all occured at the same time as my Iphone and Ipod headphones only played mono (no, the "mono" option is not on). How can there be audio issue for all these devices?

    My IPad 2 external speaker does not work and the original headphones have popping sound when used. This all occurred at the same time as my IPhone and IPod headphones only plays mono (and no, the "mono" option is not on) with the original headphones, as well as, other headphones tested.  How can there be audio issue for all these devices at the same time?
    As you may have noted from the list of Apple devices I own, I believed in the Apple and the products it was producing; but it is hard to believe from my experience and the other voices within the Apple Community that we are all experiencing the same hardware issues. Especially since I recently, I upgraded to an IPhone 4g (no, my faith in IPhone 5 series is very little) and is experiencing the same audio problem as described above. So now, I am off to the Apple store again to be told that it’s a hardware problem on new IPhone. Really? Apple, what happen to the pride in the product you were producing?

    Everyone does things a little differently. I love to "jam " along with iTunes ( or old Lp's) . Always have. That's where/how I've learned to play .
    I'm sure leonieDF is giving a proper way to jam along on a keyboard with an iTune. He blows my mind all the time with what he knows. Nuff respects to him !
    What I do is make a GB project I call "Jam With". I'll make several new tracks that are blank. Just has a few instruments named in the blank tracks. You can change those per song ...
    Because I'm not concerned about changing the pitch / key.... of the iTune or the tempo ... I can simply play along with it.
    Peace,
    P. Dreadie

  • I have recently updated my iTunes to the latest software. Since then my iphone will not sync with the computer, it doesn't show up in my computer any more. The computer makes the bing sound as I plug in but i am unable to sync, how can I fix this problem?

    I have recently updated my iTunes to the latest software. Since then my iphone will not sync with itunes, it doesn't show up in my computer any more either. The computer makes the bing sound as I plug in but i am unable to sync, how can I fix this problem?

    http://support.apple.com/kb/TS1538

  • I have bought a used macbook, to bad i do not have the admin password. is there any way to bypass this issue with out the Mac OS X disk? (without loosing my obtained files?)

    i have bought a used macbook, to bad i do not have the admin password. is there any way to bypass this issue with out the Mac OS X disk? (without loosing my obtained files?)   I NEED HELP BADLY PLEASE....

    What version of the Mac OS X are you running. Go to the Apple in the upper left corner and select About This Mac and post the version.

  • Cannot get all the sounds in library to download. I get this message GarageBand was not able to install the new sounds. Close and re-open GarageBand to download and install them again.

    When I attempt to download all the sounds in my Garage Band library, I get this message.
    "GarageBand was not able to install the new sounds. Close and re-open GarageBand to download and install them again". When I do this, I get the same message again.
    CAn anyone advise how to get all the sounds in my Garageband library?

    the same here for the drummers sounds in garageband 10xxx

  • I too am getting the tritone sound every day at 2 17 pm with no message or notification on my 4s, has anyone solved this problem yet since 09? thanks

    I have been getting the tritone sound at 2 :17 pm every day for a while now with no message or notification to back it up , I think  this has been a long term problem since 2009 according to your past discussions , so has anyone solved this problem yet? 1phone 4s system ios 6.1.3. Driving me crazy diving for the phone and seeing a blank screen , feel like someone some where is saying 'got ya' and laughing their butt off every time.

    I have been getting the tritone sound at 2 :17 pm every day for a while now with no message or notification to back it up , I think  this has been a long term problem since 2009 according to your past discussions , so has anyone solved this problem yet? 1phone 4s system ios 6.1.3. Driving me crazy diving for the phone and seeing a blank screen , feel like someone some where is saying 'got ya' and laughing their butt off every time.

Maybe you are looking for

  • Acrobat X problem with ClearScan in Windows 7

    Using Acrobat X (10.1.2) Standard on WIndows 7 Pro. I have been scanning documents with OCR set to 'Searchable text' for months. I like the ClearScan option better, but when I changed the scanning options to use it Windows reported 'Acrobat has stopp

  • Mask slowly migrates across screen for no apparent reason

    I am putting together scrolling credits but I don't want the text to start and end at the top/bottom edges of the screen.  Instead I am trying to place a mask in the center of the screen so that the text enters and exits the scroll from within the sc

  • Error message when try to run copied java program

    Hi Java Guru, Can somebody help me with this issue ? I was copy my java source from java_ulangan2 to java_ulangan20, when i tried to run the java program, i get an error message. Below is the error message: 05/01/2010 1:02:42 PM /userOut/deploy (com.

  • Flash Player Question for Adobe

    Hi I am new at this, I posted a Question a day ago under Flash Player 111 people have looked but no answer. I can watch Videos & Animation the only thing that will not work is Adobe download, the screen freezes every time after telling me it cannot i

  • TS4057 Further advice required ... this didn't work.

    I have followed the advice given here but none of the apps will show in purchases or allow an update.  They all show their original price on the app store tab and will not show in my app store purchases whether i search hidden or viewed ... can anyon