How do i play sound in java??

hello,
How do i play sound in java??
im new to java
thanks,

There are crude abilities to play sound in the core of java. If you really want to make good sound apps though you should look at the JMF.
http://java.sun.com/products/java-media/jmf/

Similar Messages

  • How can I play sound from my MacBook Pro through my iMac?

    I have a MacBook pro which I am looking to use for only iTunes or Spotify for the time being but the iMac built in speakers are better.
    I am internet sharing from an ethernet on my iMac and the Macbook pro is connected to the shared network.
    Can I play music from Spotify on my macbook pro but out of my iMac speakers?
    Thanks
    James

    For sound, try the audio output port and connecting to the RCA  audio input ports on your Pioneer receiver.  Use something like this:
    http://eshop.macsales.com/item/OWC/PODCONNECTOR/
    Ciao.

  • How I can play sound in Applet?

    I have one Button on my Applet and I want that when I click on Button audio file MySound.wav will play. I am using AWT for creating applet.

    Hi,
    You can try java api - Java Media Framework(JMF)

  • How do I play a sound?

    How do I play sound?

    It depends on the duration of the sound and how often it will be used. For sound effects less that 5 seconds, the System Sound methods in the AudioToolbox framework are a good choice. I'm just now trying to remember the sample project that has the best sample code for this purpose. It will be easier to just paste in my own class:
    // SoundEffect.h
    #import <UIKit/UIKit.h>
    #import <AudioToolbox/AudioToolbox.h>
    @interface SoundEffect : NSObject {
    SystemSoundID ssId;
    -(id)initWithFileName:(NSString*)name andExt:(NSString*)ext;
    -(void)playSound;
    @end
    // SoundEffect.m
    #import "SoundEffect.h"
    @implementation SoundEffect
    -(void)playSound {
    AudioServicesPlaySystemSound(ssId);
    -(id)initWithFileName:(NSString*)name andExt:(NSString*)ext {
    if (![super init])
    return nil;
    // NSLog(@"initWithFileName: %@.%@", name, ext);
    // Get path inside appl package
    NSString *resPath = [[NSBundle mainBundle] pathForResource:name ofType:ext];
    if (resPath == nil) {
    NSLog(@"resPath = nil");
    return nil;
    // NSLog(@"resPath = %@", resPath);
    NSURL *myURLRef = [NSURL fileURLWithPath:resPath isDirectory:NO];
    // NSLog(@"myURLRef = %@", myURLRef);
    OSStatus ossCode = AudioServicesCreateSystemSoundID ((CFURLRef)myURLRef, &ssId);
    if (ossCode) {
    NSLog(@"ossCode = %X", ossCode);
    return nil;
    return self;
    -(void)dealloc {
    OSStatus ossCode = AudioServicesDisposeSystemSoundID (ssId);
    if (ossCode)
    NSLog(@"dealloc: ssId ossCode = %X", ossCode);
    [super dealloc];
    @end
    Both the simulator and the device will decide they don't like certain sounds. That can be confusing because it's not uncommon to be able to play a sound on the simulator that won't play on the device, and vice-versa. When that happens you'll see an error code in the console (uncomment more of the logging to see the whole story). I forgot the code for an unacceptable format, but you'll learn it soon enough. Often the solution is to just convert the file to a different format. When I was trying out the sounds that came with OS X, I found that the device didn't like any of the .caf files. It couldn't play those sounds until I opened the files in Audacity® and resaved them as a different size .caf.
    Hope that helps!
    - Ray

  • Playing sound in a JSP

    How do I play sound in a JSP page with out using the <EMBED> tag? I tried using the
    java.applet.* but I keep getting errors.
    Thanks

    try using Java's Multimedia Framework ... JMF

  • Sound in Java Program - Tetris

    Hello, I am a student and I just completed my final assignment for my Java class, I was supposed to make a tetris program, im sure you guys have heard of these types of assignments, anyways I would like to add some extra stuff to the assignment, namely, sound, a background song, and a click noise when blocks drop/a line is cleared, I already know how I will implement these things, I just dont know how to work with sound in Java, so if you guys could link to a few tutorials I would really appreciate it, I don't want to use anything outside of the api though so no 3rd party stuff.
    I also am wondering about how to implement some cool things I was thinking about doing, for instance:
    Its been said that there is no way to win tetris because your destined to lose eventually, for that reason most people add a scoreboard to their game so that they can have high scores as a way for making up for not winning, im adding a second element to that, this is something that I already know how to implement, as soon as the game ends, if you are on the high score table, you are presented with a new death match game which is played at the hardest level and if you are able to score half of the points that you scored on the original game you are a winner at which point comes the hard part:
    I was thinking about adding some effects like when you win solitaire in windows and those firework style things go off, except taking that to a new level, I dont know if this is possible, I don't know how to do the fireworks style thing, also I wanted to do it so that the fireworks encompass the whole screen not just the original game screen, for this I was thinking maybe a fully transparent frame that is auto maximized and closes after the animation is done, if anyone could help me with implementing something like this I would really appreciate it.

    if anyone could help me with implementing something like this I would really appreciate it.This forum is conducive for providing help where one asks a specific question about some aspect of Java development. Up to this point, you've described your project and some high-level ideas about it, but you're not clear on what help you need. If it's general end-to-end project assistance, you'd do better to find a helpful peer or start up an open-source project, as this forum is not appropriate for such a thing. If you ho have a specific question or problem, please feel free to ask, but be sure to post the necessary detail for others to help.
    ~

  • Playing sound from my macbook to my imac

    I'm using my iMac as an external display for my macbook pro. Since my iMac does not support thurderbolt, I've had to connect it using a Mini displayport. I've bought a 3.5mm Male to Male Stereo Cable so I could play the sound from my macbook through my iMac but both go silent. Anyone have any suggestion on how I could play sound on my macbook through my iMac?  Thanks in advance.

    Firstn make sure that the male audio cable is plugged into the "audio out" port on the MacBook and is plugged into the "audio in" port on the iMac. Second make sure you are in the MacBook system preferences (Not the iMac) then click headphones. The thing named "Headphones" is your iMac. I hope that helped

  • Play Sound Through Display AND Connected Computer.

    I bought and connected my new 27" LED Display to my 27" iMac today and would like to know if its possible to play sound through both the display AND the computer at the same time. I know to go into the sound settings in system preferences, however only the option is given to chose the sound output to come from either one or the other.
    Is it possible to play the audio through both?
    Thanks in advance!

    I downloaded this program with the provided link - after changing the settings as advised I began to get that loud static white noise like sound out of the iMac speakers (which apparently is a problem many people have experienced with their 27" i7 iMacs). As soon as I deleted the Audio Hijack program the speakers went back to normal. (Thank God!)
    If anyone else has any suggestions as to how I can play sound through both the iMac and the display at the same time this would be great appreciated.
    Thanks for trying to help though Malcom

  • Play sounds/music as if speaking through microphone (X-Fi Elite Pr

    Does anyone know how I can play sounds or music in programs like Teamspeak, Ventrilo, or PC games with voice capabilities using my sound card (X-Fi Elite Pro) as if I was talking through an external microphone?
    Thank you.
    -Cam
    Message Edited by delta5888 on 06-04-2008 0:48 PMMessage Edited by delta5888 on 06-04-2008 0:49 PM

    <SPAN>Hey man, thanks for pointing me in the right direction! I started messing around with the Phono 2 dials on the unit and was having no luck what so ever. I then wanted to try my microphone to make sure that it was still working from all the changes I had made. Well, when I hit the record button and talked into my mic it showed something being recorded, so I knew my mic was still working... But.... when I played the recording, It was the recording from the T.V.!!! At this point I knew I was close to getting this issue solved.
    <SPAN>
    <SPAN><SPAN>I ended up having to open my "Sounds & Audio" controller within the Windows XP Control Panel and then going to the volume section of the XF-I card and then going to file, properties, and then check the "Phono 2" port off so that I could see it listed with all of my other volume and sounds controls. I then un-muted it as you said and Bam!!!!!!! Guitar Hero on my PS2 was pumping out at my full 500W!!!! I nearly went death from the experience, but it was very gratifying!!!
    <SPAN>
    <SPAN><SPAN>Thanks for your post. It really helped to point me in the right direction. I'm now thinking of digitizing all my vinal records now into MP3's too! Thanks again man, you?re the bomb!
    <SPAN>
    <SPAN>Jeep

  • How to Play a sample sound using Java

    Hi,
    I have an mp3 music files in database. When a user chooses a particular button, all the songs are fetched from the database.
    I have two buttons namely, 'Buy' and 'Play Sample'. If I click the 'Play Sample' button, a sample of the song has to be played (not the full song). If the user likes the sample, he can buy the full song.
    My question is how to achieve the 'Play Sample' using Java Swings and Sound. I have googled, but not find any solutions. Please provide me an example or link.
    Thanks in advance.

    HI
    Actually i am trying to create a JFrame which plays an mp3 music file
    with the help of play and stop buttons in it ...
    i splitted the frame into two
    i want a music file list in the first frame (JComboBox)
    and want to have play and stop button in the second frame .
    i had tried out some code in which the frame part is fine ,,,
    but i am not knowing how to play the file with those buttons ...
    here is the code and plz help me to move further ...
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    public class AudioFile extends JFrame {
        public AudioFile() {
            setTitle("Music File");
            setSize(300, 400);
            JPanel jp1 = new JPanel();
            JPanel jp2 = new JPanel();
            JButton s= new JButton("STOP");
            JButton p= new JButton("PLAY");
            JLabel j1 = new JLabel("MusicFile");
            String[] musicfiles={"file:///home/swathi/Desktop/spot3.mp3","anitha.mp3"};
            JComboBox musiclist=new JComboBox(musicfiles);
            musiclist.setSelectedIndex(1);
            jp1.add(j1);
            jp1.add(musiclist);
            jp2.add(s);
            jp2.add(p);
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                    true, jp1, jp2);
            splitPane.setOneTouchExpandable(true);
            getContentPane().add(splitPane);
        public static void main(String[] args) {
          AudioFile sp = new AudioFile();
            sp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            sp.setVisible(true);
    }

  • How to play sound after clicking on an object?

    Can anyone explain me how to play a sound in java when I click on a particular object? I have read lots of threads but couldn't find anything. All I want is a short sound(3,4 seconds) to be played each time I click on an object. I know I need to use Sound API but I cannot find anything helpful
    Thanks in advance

    flounder wrote:
    ProGenius wrote:
    I have read lots of threads but couldn't find anything.
    [I found lots of info|http://lmgtfy.com/?q=java+audioclip]
    that is knowing you can use audioclip. Even searching for "java sound tutorial" gives many good resources, including the sun trail:
    http://java.sun.com/docs/books/tutorial/sound/index.html

  • How to play sounds on Frames

    I'm been working with sounds on applets and is pretty easy play sounds and build funny stuff.
    But now i need to play sounds on a Frame (Application) and i realize that sounds can be load only on applets(so far thats what i know)
    If anyone knows how play sounds without an applet please let me know this is a huge issue for me.
    thanks in advance.
    Andrey

    See the following thread for a sample program:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=97984

  • 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.

  • 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);
    }

  • How do I tell Apple to fix their software like apps that play sound even though the sound is turned off and not being able to disable features you hate like game center

    Apple is suppose to be the pinnacle of usability and, yet, I want to throw my new IPhone 4s as far as I can and watch is smash into a million pieces on concrete. Seriously, I've already got three things that irritate the **** out of me. First, there are Apple apps that insist on playing sound even though the sound is turned off. If I flick a switch to turn the sound off, I want the sound off!!!! Second, if I do not want a totally unnecessary feature like Game Center, I should be able to disable it. I completed most of the Angry Bird levels with 2 or 3 stars and now I have to start over from square one. Maybe, this happened when I upgraded to the 4s but it sure seemed to happen when I joined Game Center. Tomorrow, I am going to reset my 4s to factory defaults to try to get rid of my Game Center account. I don't want Game Center! I do need Game Center! I hate Game Center! Finally, I had an alarm go off to wake me up and there was a Snooze button but no button to turn the alarm off. I flicked the slider to access the main screen expecting to see something to turn the alarm off but there was nothing. The alarm just kept alarming. I had to warm boot my IPhone to shut the alarm off! Really, Apple!!!!

    The sound is turned off. Only, some Apple apps like YouTube and Siri make sound when the sound is turned off. It is very embarrassing when this happens at work. My question was how do I tell Apple to fix this?
    Turning off game center does not work. The games just prompt me to sign in when they are started.I have tried everything I can find online to stop this behavior. It is annoying and should not happen. My question was how do I tell Apple to fix this?
    The alarm went off. There was a green thing that looked like a button but pressing it did nothing. There was a red button that said snooze. I did not want to snooze. I wanted to turn the alarm off. I slid the bar to unlock the phone and there were no running apps with a button to press. The alarm just keep running. I have not had this problem since it first occurred. The alarm now shuts off when I just unlock the phone. It may have happened because I had another alarm app running. The two may have interfered with each other. I would like to tell Apple about it.
    It also annoys me that the button that closes apps leaves the phone app running. If I press on a number at 6:00 AM to get information about who called me, the phone automatically dials the person back and my natural reaction is to press on the button to close the phone app but the phone keeps dialing this person at 6:00 AM. It is a bad design. I would like to tell Apple about it.
    Finally, I looked all over Apple's site to try to find someplace I could send them a polite message to let them know that I was not happy with these "features" but could not find anything. It is extremely frustrating to have issues with a product and not being able to tell the manufacturer about it. So, you grow up!.
    When trying to fix the Game Center issue, I saw a link someone posted to report issues with the IPad to Apple. The answer I am looking for is where is the link to report issues with the IPhone.

Maybe you are looking for

  • Invalid Partition Boot Sector??

    Hi all, I've just completed the build of a new PC. Post resetting the CMOS I get the AMI screen which shows the BIOS details, below which I see a ', 2GHz'(?) and below this is 'CMOS settings wrong'. If I select default settings I then get 'Invalid pa

  • Wat is the procedure to make a release strategy in sales order ?

    wat is the procedure to make a release strategy in sales order ?

  • [SOLVED] Problem installing gnome-extra packages

    I have completed the installation and all that left is gnome-extra packages. I fetched the packages and after the integrity check it says Failed to commit transaction invalid or corrupted packages gnome-games-3.0.21- <pacgae_info> is either invalid o

  • Windows 8.1 compatability

    I have Windows 8.1 and using Adobe Elements 12.   Can I install Adobe Premiere Elements 10?    Are they compatible please?

  • Sleep/Wake Button is either jammed or broken

    the sleep/wake button somehow jammed or is broken, my ipod now only works when its in the Ihome and when its not in the ihome i cant change music or practically anything for that matter. what do i do