Help playing a sound file please...

i am trying to play a sound file everytime a button is clicked. the sound will play the first time the button is clicked but wont play after that. how can i get the sound file to play everytime the button is clicked?? here's how i play the sound file...
InputStream in = new FileInputStream(sound.wav);
AudioStream as = new AudioStream(in);
// in the button action event...
AudioPlayer.player.start(as);
i tried adding this line... AudioPlayer.player.stop(as);...before the...AudioPlayer.player.start(as); -- the sound file still only plays once
any help appreciated...thanks

Hi there,
Is there a class AudioPlayer in the API or is it yours. Anyway, your class must implement AudioClip interface. Then call yourClass.play(as); You dont need to stop, each time you call play(), it restarts. Try and let me know.
cheers

Similar Messages

  • I am using a mini display to hdmi with my macbook and the display works fine. However, the sound will only play iTunes such as music and movies but when i go online to watch movies on youtube it will not play any sound. Please help

    I am using a mini display to hdmi with my macbook and the display works fine. However, the sound will only play iTunes such as music and movies but when i go online to watch movies on youtube it will not play any sound. Please help

    HDCP maybe? Read this http://www.macnn.com/articles/08/11/26/displayport.drm.conflict/

  • How do i play two sound file one after another

    Hi All,
    How do i play two sound file one after another using single AudioClip Component?.
    Advance in thanks
    Manivel

    AudioClip gives you very little control over what happens to the sound, it also isn't capable of playing long clips or waiting until a clip ends. It will play multiple clips over top of each other.
    To do what you want you should use the facilities of javax.sound. Here's a post with an example: http://forum.java.sun.com/thread.jspa?forumID=513&threadID=450768
    There is also a tutorial, but its example fails for long clips.

  • Please tell me how to automatically play a sound file in a PDF slideshow?Da

    I use PS CS3, LR2, and now I purchased Acrobat 9.1 Pro.  My intent is to create an image based full screen automatic slideshow WITH SOUND.  I have everything working well but I can't figure out how to get the sound file to simply play along with the images.  I do not want the viewer to have to press anything to hear the sounds.  The sound file should simply play along with the image(s).  I would like to be able to time the sound file to the images as well.
    I will appreciate any pointers you may have.
    Thanks...

    To do this reliably the document has to be in the list of the client applications list of trusted documents.  You get this prompt when you attempt to play a sound.  The other way is to actually set the Multimedia Trust (legacy) preference on each client for each type of Player application.  While this might seem a bit of a task it's meant to protect the user.

  • Urgent Help Regarding Using Sound Files

    Hello,
    Using Java is it possible to
    a) represent a .WAV file in WAVE FORM Format (Graph) output.i.e to represent a
    audio file pictorially.
    b) Spilit a .WAV file into n small pieces or portions.
    Please guide me in this regard.Its Urgent
    Thankz

    Hello,
    Using Java is it possible to
    a) represent a .WAV file in WAVE FORM Format (Graph)
    output.i.e to represent a
    audio file pictorially.Open the AudioInputStream, read the AudioFormat, then read the frames one at a time and plot the data.
    Here's some code that plays a wave file using the AudioInputStream. Java Sound, see reply 2. this shows how to open the file and get the format, it just plays it, but is able to plays it, but it does read frames. This should provide a start for you.
    b) Spilit a .WAV file into n small pieces or portions.Yes, see the classes in package javax.sound.sampled.
    >
    >
    Please guide me in this regard.Its UrgentDon't mark your posts as urgent, don't cross post.
    ThankzYou're welcome, hope this helps

  • How to play downloaded sound files?

    I 'save as' sound files from a nature recordist's group - usually mp3s- but I cant play them.
    Help? I know this is the place.
    Thanks
    ibook G4, B&W G3, Pismo G3   Mac OS X (10.4)   0S 9.2, Peak Le

    As Duane says, iTunes should play MP3. If you have downloaded to, say, the desktop, iTunes will not automatically play it. But if you double click it, iTunes should automatically open and import the song as long as iTunes has been set as your default player. If that doesn't work, occasionally you need to drag & drop the file into an open iTunes window. If that doesn't work the file is corrupt or isn't MP3 even if the download says it is.
    Have fun!
    Adrian

  • Play multiple sound files in different frames from library in flash

    My assessment task for college is to create a webpage of my work.  So far it runs brilliantly except for this.  I only need this to be working in like 2 days!  Help!
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Carolyns_Media_Portfolio_Scene1_fla::MainTimeline/frame5()
    at flash.display::MovieClip/gotoAndStop()
    Trying to be able to play sound clips from the library with the option to play and stop the sound file. Each sound has its own frame, with stop and play buttons. I can run the first sound file perfectly being able to start and stop it but when trying to play the next sound it creates the above error on output. I have dead buttons as well on the second sound.
    The top buttons take you to each scene
    The script runs from frame 5.
    import flash.events.MouseEvent;
    **buTrivia.addEventListener(MouseEvent.CLICK,clickListener7);
    function clickListener7(event:MouseEvent):void {
    SoundMixer.stopAll()
    gotoAndStop("trivia");
    buToyRA.addEventListener(MouseEvent.CLICK,clickListener8);
    function clickListener8(event:MouseEvent):void {
    SoundMixer.stopAll()
    gotoAndStop("toyminatorRA");
    buCaroline.addEventListener(MouseEvent.CLICK,clickListener9);
    function clickListener9(event:MouseEvent):void {
    SoundMixer.stopAll()
    gotoAndStop("caroline");
    buServerDown.addEventListener(MouseEvent.CLICK,clickListener10);
    function clickListener10(event:MouseEvent):void {
    SoundMixer.stopAll()
    gotoAndStop("serverdown");
    This was the script I found and edited.  Only Trivia works
    stop();
    var triviaSound:trivia = new trivia()
    var triviaChannel:SoundChannel = new SoundChannel();
    buplay1.addEventListener(MouseEvent.CLICK, playSound1);
    buStop1.addEventListener(MouseEvent.CLICK, stopSound1)
    function playSound1(event:MouseEvent):void
    triviaSound.play();
    function stopSound1(event:MouseEvent):void
    SoundMixer.stopAll()
    gotoAndStop("trivia");
    /*buplay2.addEventListener(MouseEvent.CLICK, playSound2);
    bustop2.addEventListener(MouseEvent.CLICK, stopSound2)
    var toysSound:toys = new toys();
    var toysChannel:SoundChannel = new SoundChannel();
    function playSound2(event:MouseEvent):void
    toysSound.play();
    function stopSound2(event:MouseEvent):void
    SoundMixer.stopAll()
    gotoAndStop("toyminatorRA");
    Basically I want to play all the sounds, from the library, individually in different frames using the option to play and stop that sound.  I found the above script but only works for one sound.  I am new at scripting in flash so any help or even a better script option would be awesome.  Thank you

    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
    - is declared but not instantiated
    - doesn't have an instance name (or the instance name is mispelled)
    - does not exist in the frame where that code is trying to talk to it
    - is animated into place but is not assigned instance names in every keyframe for it
    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

  • How can i play a sound file in form 10g

    hi every body ,
    would any one help me with my problem
    *I 'd like to play a soend wave file _ say when press a button _*
    In forms 6i
    it was too easy,
    Read_sound_File('c:\aaa.wav', 'wav', 'emp.sound');
    Go_Item('emp.sound ');
    play_sound('emp.sound');
    But it doesn't work in 10g
    and there is n't read_sound_file in help of 10g
    is there any compatability with this instruction in forms 10g
    or how can i use sound file in 10g
    is it with webUtil ( i' ve configured it correctly )
    *or with java beans _ plz help me with it _*
    Thanks _ waiting for u answers _ plzzzzzzzzzzzzzzzz

         I 'd like to play a soend wave file _ say when press a button package sound;
    import oracle.forms.ui.VButton;
    import java.applet.AudioClip;
    import java.applet.Applet;
    import java.net.URL;
    import oracle.forms.properties.ID;
    public class sound extends VButton
    public final static ID PLAY = ID.registerProperty("PLAY");
    public String sou_loc = "FILE:///C:\EAM_original.wav" ;
    public sound()
    public boolean setProperty(ID p0, Object p1)
    if (p0==PLAY)
    { try
    sou_loc = p1.toString();
    URL sou = new URL(sou_loc);
    AudioClip clip = Applet.newAudioClip(sou);
    clip.play();
    } catch (Exception ex)
    {ex.printStackTrace();}
    return super.setProperty(p0, p1);
    }

  • Need Help playing a wav file on PDA

    Does anyone have a SIMPLE example of playing a wav file on a PDA using LabView PDA. The only working example I can find from NI "Advance Sound Example for LabVIEW PDA for Pocket PC" is a jumbled of confusing functionality. I'm mainly looking for a simple "play" example, but a simple "record" example would be helpful also.
    Thanks - Bruce

    Hello,
    Well, I looked through the example code I tried to break it down to the point where you could create a simple Play VI. Unfortunately, I don't have the PDA target, so I'm uncertain if the little example that I have attached will run or not. If not, I also took a screen shot so you can see what VIs I used. I'm pretty sure I only used VI's that I found on the example itself.
    Good luck.
    Attachments:
    Play_Wav_PDA.vi ‏55 KB
    Play_Wav_PDA.bmp ‏1029 KB

  • Problem, trying to play many sound files

    hello,
    I did not find a specific answer to my question in most of the archives and so I am posting here.
    my problem is that I have to play a sound when mouse moves over an object and another sound when the same object is clicked.
    there are many such items on the screen and so it is expected that when the mouse entered from the mouse listener is fired, the sound must play.
    but what really happens is that when the mouse moves over the first object the sound plays all right. but there is no sound played when the mouse click happens.
    I have properly loaded the sound files and I am sure that the code is right.
    infact the major thing that has frustrated me is that if I move the mouse on an opject (an icon) the sound is properly played. and if I wait for a long time and then move the mouse on another icon the other sound is played as well. but if I move the mouse quickly from one object to another no sound is played for the second object. or if I click the mouse on an icon after a long holt even the click sound playes.
    what could be the problem. why is it that sound only play when the actions are done after long haults?
    is it an issue of java performance. should I try to do the sound playing stuff in different threads for each icon's mouse events?
    I also tried to stop the file on the mouse exit method to make sure that there is no sound left playing.
    this game is depending a lot on mouse movements with sounds and so I have to get the sounds playing at the same time mouse moves over the objects.
    I use the audioClip to load my sounds with the method in the applet class.
    I really don't know abt the latest java media api and will like to know if that is what I must use for my task or audioClip is ok with me.
    thanks
    Krishnakant.

    I dont know exactly, but I dont know if applets support various files at one time.
    Have your tried to do that with javax.media or with javax.sound.sampled?
    Or could your post the code?
    R. Hollenstein

  • Mail app no longer plays QuickTime sound files.

    Before upgrading to Mountain Lion, I was able to play sound files attached to mail within the app.
    In other words, if someone sent me a sound file, it would appear as a QuickTime sound within the body of the email and I could play it.
    That was a very nice feature.
    Now sound files will not play within the mail window. Instead, I need an external player such as QuickTime Player or iTunes.
    How can I get that feature back?

    What specific sound file types will not play as Mail attachments in Mountain Lion?
    I just sent an .m4r (ringtone), mp3, and .m4a (iTunes aac music) files as Mail attachments. The first appeared as an icon that played via QuickLook from within Mail. The second two appeared as black, QuickTime styled, embedded music play bar attachments. They played back flawlessly.
    Have you installed any application recently that may have hi-jacked the default QuickTime audio playback? It would have done so silently, or popped up a dialog requesting to perform the hi-jack on a list of music file formats.
    You may have to select each particular audio file format in Finder Get Info and restore QuickTime in the Open with section on that panel.

  • How to play wikipedia sound files (Ogg) in Safari 6.0.3?

    I'm pretty sure the answer to this one is that it can't be done, but just in case I've missed something in my web searching. I used to be able to play them under OSX 10.6.8. For instance, these sound files: http://en.wikipedia.org/wiki/Beethoven_symphony_5

    Please link to a page you're having trouble with, if possible.

  • Problem with playing a sound file.

    Hi,
    I simply want to play a sound by a button click. I imported
    <AVFoundation/AVAudioPlayer.h>. The code block is here:
    In .h file:
    #import <UIKit/UIKit.h>
    #import <AVFoundation/AVAudioPlayer.h>
    @interface PlaySoundViewController : UIViewController <AVAudioPlayerDelegate>
    in .m file:
    -(IBAction)btnPlay:(id)sender
        //Get the filename of the sound file:
        NSString *path = [[NSBundle mainBundle] pathForResource:@"REC001" ofType:@"MP3"];
        AVAudioPlayer* thePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];//error here as it will compile if I commented it (and two line after) out.
        thePlayer.delegate = self;
        [thePlayer play];   
    Everything looks fine but it failed when I tried to run it. Looks like it cannot find my sound file "REC001.MP3". I put it in folder ".../PlaySound/Resource Files/SoundFiles/REC001.MP3", and "PlaySound" is my project name. However the path returned is ".../PlaySound/REC001.MP3". I guess this is why it cannot find the object. But it didn't work even I put the sound file under "PlaySound" directly. Anyone has a solution?
    Thanks.
    Regards,
    Taizhi

    Hi Mark,
    Thanks for the reply. Based on your instruction, I checked and I can see the sound files in Build Phases. The location is ".../PlaySound/SoundFiles/REC001.MP3". I don't know why it ignores folder "Resource Files". I guess that is the way it is as I also can see other images in different folders which are shown properly in the project.
    The detailed error message is here:
    Ld "/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpxz lqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator/PlaySound.app/PlaySound" normal i386
        cd "/Users/greatzhi2001/Desktop/iProjects/PlaySound"
        setenv MACOSX_DEPLOYMENT_TARGET 10.6
        setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr /bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3 .sdk -L/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpx zlqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator -F/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpx zlqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator "-F/Users/greatzhi2001/Desktop/iProjects/PlaySound" -filelist "/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpxz lqfodwbuqqjwjzcd/Build/Intermediates/PlaySound.build/Debug-iphonesimulator/PlayS ound.build/Objects-normal/i386/PlaySound.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/greatzhi2001/Library/Developer/Xcode/DerivedData/PlaySound-anydnuuxbpxz lqfodwbuqqjwjzcd/Build/Products/Debug-iphonesimulator/PlaySound.app/PlaySound"
    Undefined symbols for architecture i386:
      "_OBJC_CLASS_$_AVAudioPlayer", referenced from:
          objc-class-ref in PlaySoundViewController.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status
    Is the framework AVFoundation I added wrong? Thanks.
    Regards,
    Taizhi

  • Help Playing a MP3 files in a java application!

    Hey, i need help playing MP3 files in a JFrame application. Any help is apperciated.

    Google for JLayer.

  • Playing local sound file

    I need to play an mp3 file in my AIR app. But I won't
    necessarily know the path to the file because I need to use things
    like the storage directory. So, would I have to do something like
    this to get that done:
    var file:File =
    File.applicationStorageDirectory.resolvePath("path/to/mp3");
    var urlRequest:URLRequest = new URLRequest(file.nativePath);
    and then load the sound from that? Or is there some way that
    AIR has provided to skip the first step?
    Thanks!
    Kyle

    @ paus akid,
    There are two things wrong here.
    One, you should never use a nativePath in place of a URL.
    This happens to work on Windows because the nativePath is
    interpreted as an absolute path. However, on Mac and Linux, a
    nativePath is indistinguishable from a relative URL. Since relative
    URLs are resolved against the application directory (in general),
    you get the app:/ URL scheme. So change:
    var req:URLRequest = new URLRequest(file.nativePath);
    to:
    var req:URLRequest = new URLRequest(file.url);
    The second issue is that you don't initialize your file
    object before using it to resolve a second path. Instead of:
    var file:File = new File();
    file = file.resolvePath(currentRandomSong);
    You should do something like this (using the appropriate
    directory):
    var file:File = File.usersDirectory("path/to/mp3");
    See
    Developing
    cross-platform AIR applications for more information.

Maybe you are looking for