Playing audio in an application

How does one play an audio (.wav) referenced by an URL in a java application? I remember reading somewhere that Applet has an static method doing this, but was unable to find it from the API. Thanks in advance

Wouldn't this be it?
void play(URL url)
Plays the audio clip at the specified absolute URL.
Don't know whether it would work with .wav files, though.

Similar Messages

  • Play Audio File in application

    Hello all.
    Can anybody tell me how can I play some Audio File from my application?
    I think that it's impossible. (I can play Audio File only if i will use java.applet.AudioClip).
    I know that some classes in sun.*.*... can play Audio File.
    And I want to know why developers cann't make them easy of access.
    Thank you,
    Dmitry

    There are 2 ways you can play audio in an application. The of audio tools packaged with applets can be adapted to work in an application. Unfortunately, I do not know how to do this. I have had more success with sun.audio.*, but have been unable to find any documentation on it, which makes it very limiting.

  • How to play audio in an application?? (HELP ME PLEASE!!)

    Hi! I'm studying computer science and I'm programming in Java for my last project of this period. I've been trying to play sound in an application but I haven't been able to. My teacher gave me a piece of code that looked like this:
    try{
    URL url=new URL("http://hostname/audio.au");
    AudioClip ac=Applet.new AudioClip(url);
    ac.play();
    }catch (MalformedURLException e){
    This is the code for my program:
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.applet.AudioClip;
    import java.applet.AudioClip.*;
    public class Sonido extends Frame implements AudioClip{
         public Sonido(){
              this.setSize(new Dimension(300,200));
              this.setTitle("Testing");
              this.setLayout(new BorderLayout());
              this.add(new Button("Music"), BorderLayout.CENTER);
              addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                        System.exit(0);
         public static void main(String [] args){
              Sonido sound=new Sonido();
              sound.show();
              try{
                   URL url=new URL("C://toolate02.au");
                   AudioClip ac=new AudioClip(url);
                   ac.play();
              catch(MalformedURLException e){
    It is only a test but I have to get it to work because the teacher wants the sound to play forever! (with loop() I guess). Anyway, I don't know how to implement the methods of the AudioClip interface. Any help would be great!!! Thank you very much.
    Vanessa.

    This is probably too late to help you, but if you're using Java 1.3 or higher, you can use the javax.sound.sampled package to play .au's, .aiff's, and .wav's (but not .mp3's... support for those comes from Java Media Framework [JMF] or QuickTime for Java [QTJ])
    Anyways, this app plays a single file specified on the command line, like:
    java SimpleSound mailbag.aiff
    import javax.sound.sampled.*;
    import java.io.*;
    public class SimpleSound extends Object {
        public static void main (String[] args) {
            if (args.length < 1) {
                System.out.println ("Usage: SimpleSound <file-path>");
                return;
            try {
                Line.Info linfo = new Line.Info (Clip.class);
                Line line = AudioSystem.getLine (linfo);
                Clip clip = (Clip) line;
                File file = new File (args[0]);
                AudioInputStream ais = AudioSystem.getAudioInputStream(file);
                clip.open (ais);
                clip.start();
            } catch (Exception e) {
                e.printStackTrace();
    }Works for me on Mac OS X. .aiff's sound good but .au's sound awful. Your mileage may vary.
    More info on the JavaSound page -- http://java.sun.com/products/java-media/sound/index.html
    --Chris (invalidname)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • No Audio From Any Application Unless PP Is The Active Application

    Weird issue I have never seen before. If Premier Pro is running and you are attempting to play audio from another application, that audio output will cut out unless PP is the currently selected active application.
    EX:   Trying to play a song in iTunes or streaming a video from Youtube while Premier Pro is running will result in no audio until you switch back over to using PP then the other application's sound will start playing.
    Additional info: Blackmagic drivers are installed on this machine. We've tried multiple settings for audio within PP but none have resolved this issue.
    Hopefully someone has an idea of what is going on here. Starting to drive us crazy.

    Not on my machine.  I can have both PPro and Audition open on my PC with audition active.  I have also had PPro and the Smartsound app running with smartsound active without problems.
    You may have a driver problem.

  • Application that plays audio file at double rate

    I need to transcribe audio files and need an application that will play audio files at double their rate (and half their rate) so that I can quickly go through audio files and then concentrate on the pertinent portions.  Any suggestions of applications for Mac OS X?  Free is always good!

    Dear Matt,
         Thank you for your suggestion.  I checked it out.  As I am transcribing portions of the files, I would like to just change the playback speed, not the actual file.  It seems like, in Audacity, you actually transform the file.  I noticed to do this you use "change tempo" to avoid pitch changes.  However, by modifying the file, the file becomes longer or shorter and then I cannot reference a particular part of the file by a time (minute:second).
         Any ideas of programs that could do this?  Or does Audacity do this?

  • Satellite L-50 can't play audio from multiple sources

    I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube video playing, youtube video doesn't have sound..
    I already have all the latest drivers, last DTS driver update was in 2014, sound update this year's february..
    25/02/14
    DTS Studio Sound
    DTS Inc.
    Windows 8.1 - 64 Bit
    1.01.2700
     I don't know if this makes sense, but I got newer DTS sound driver which I found, It's not my laptop model, but they all seem to be the same - v1.1.88.0 
    I uninstalled DTS software and still had the same problem, so it's not affecting sound driver in any way..
    10/02/15
    Sound Driver
    Integrated Device Technology Inc.
    Windows 8.1 - 64 Bit
    6.10.6491.0
    IDT audio driver has newer release date, but the driver version is the same as the 2013 one..
    Why are toshiba releaseing old driver as 'NEW' ?
    2nd is my speakers advanced settings, nothing changed when I disabled "Allow applications to take exclusive control of this device"
    Attachments:
    audio.png ‏6 KB
    test2.png ‏7 KB
    specs.png ‏16 KB

    Can you check the full model and part number from the laptop?
    - Peter

  • Satellite L50-A-19N can't play audio from multiple sources

    I can't play audio from multiple sources. This is very annoying when I have 2 youtube videos playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 media players open and 1 youtube video playing, youtube video doesn't have sound..
    It goes away when I plug out my headphones..
    I already have all the latest drivers, last DTS driver update was in 2014, sound update this year's february..
    25/02/14
    DTS Studio Sound
    DTS Inc.
    Windows 8.1 - 64 Bit
    1.01.2700
    I don't know if this makes sense, but I got newer DTS sound driver which I found, It's not my laptop model, but they all seem to be the same - v1.1.88.0
    I uninstalled DTS software and still had the same problem, so it's not affecting sound driver in any way..
    10/02/15
    Sound Driver
    Integrated Device Technology Inc.
    Windows 8.1 - 64 Bit
    6.10.6491.0
    IDT audio driver has newer release date, but the driver version is the same as the 2013 one..
    Why are toshiba releaseing old driver as 'NEW' ?
    2nd is my speakers advanced settings, nothing changed when I disabled "Allow applications to take exclusive control of this device"

    I see that the option called “give exclusive mode applications priority” has been checked.
    Usually different applications and programs can access the sound card simultaneously.
    For example: you can hear the sound in game, while you can run your own music via an external player.
    This is prevented with these options “give exclusive mode applications priority”.
    Maybe you should disable (uncheck) this option to prevent the different applications for using this exclusive mode stream.
    I did it for my DAC. I set the DAC for exclusive mode. Once my audio playback software starts to play music, no other software is able to share the DAC.
    However, I use Win 7 and Realtek sound driver… It’s another configuration.
    So it’s not known to me if your issue is related Win 8.1 system or maybe limitation of sound driver… it could be also possible that one of your sound applications don’t allow multiple sound streaming.

  • Playing Audio Files in the Finder-any tips?

    Something I've been meaning to ask for ages... and hopefully an easy one to answer!
    When playing audio files in the Finder (in 10.5.8), it's really annoying when the file stops playing when you click on another window or application (or even just the Desktop). Is there any way around this?
    Someone recommended Snapper, but it's the same story - file stops playing when you click on any other area. Is this problem confined to Leopard (ie. has it been fixed in Snow Leopard?) - never used to be like this in Tiger.
    Some of us like to multi-task when listening to audio. The only solution I can see is importing the file into itunes. Any other suggestions?

    I assume you're talking about QuickLook?
    That's not the Finder, that's QuickLook.
    QuickLook is a function that can only work with the foremost selected item, and that makes sense, as you can, for example, QL a PDF within Mail.app, as well.
    Why not just use column view (doesn't everybody?) and play it in the Preview pane at the right?
    It will keep playing until you close the window or select another object within it.
    I use QuickLook when I want to give an audio file a quick once-over - skip here and there, but for actually playing it through, I use the column view preview.
    Message was edited by: spheric

  • Playing audio file while Downloading

    Hello all,
    Can anyone give me an idea on how can I play audio file while downloading.
    Thanks

    Connect the external drive and then launch Disk Utility found in Applications/Utilities. Your external drive while show up in Disk Utility's side bar. It should be Mac OS Extended or OS Extended (Journaled).
    If it isn't:
    Then select it and click the 'Erase tab' at the top.
    Select Mac OS Extended-Journaled formatting from the Volume Format menu.
    Then click the oval Erase button at the lower right. Just remember-this will erase the drive!
    http://danslagle.com/mac/iMovie/usage/5006.shtml
    Sue

  • Cannot play audio CDs in totem

    I have totem-gstreamer and the gstreamer plugins for cdaudio, cdio and cdparanoia.
    I am in the audio and optical group.
    The permissions of my cd-rom are as follows: brw-r----- 1 root audio 22, 0 2007-08-06 22:35 /dev/hdc
    The audio CD appears as an icon on my desktop when I insert it.
    No other audio application is running.
    I can play audio cds using the cdplay program cdkit provides.
    But, when I start totem the option Play Disc 'Audio CD' is greyed out.
    I've tried turning HAL off and restarting totem to no avail.
    I've tried totem-xine and still it does not work.
    The only thing that does give some food for thought is that when I kill gnome-vfs-daemon the option "Play Disc "Audio CD"" disappears...
    Help!

    Hello arbee,
    It seems certain that the problem lies with your CD player. It is well-known that many older CD players will not read CD-R discs. If you look at this two-year old discussion you'll see what the issues are for someone who had a similar experience to yourself.
    This discussion also suggests that you might get better results from using a higher-grade burning programme, such as Toast -- but nothing's certain.
    Best wishes,
    Martin
    If you found that this contribution helped to answer your question, please consider awarding some points. Why reward points?
    Powerbook 15-inch G4 1GHz   Mac OS X (10.4.8)   Several veterans that go on and on. 40gig, 3rd generation iPod

  • Flash Player 10 is not playing audio from Youtube with Vista and IE

    Since installing FP10, I cannot get audio when playing YouTube video. I'm running Vista with SP2 and IE on an HP laptop. Flash 0 on my XP desktop plays audio fine, so I'm guessing its a setting on my laptop which needs changing back to what it was before the upgrade to FP10...any ideas please? I have uninstalled and the reinstalled FP10 as per other posts on this forum, but no success.

    I too am experiencing this
    [edit]
    My problem was that I was not getting flash audio at all, including local publishes out of the IDE.  The problem was that my Windows Audio service had stopped (for some reason).
    To check :
    (classic view) :: Start > Settings > Control Panel > Administrative Tools > Services >
    (non-classic) :: Computer (right click)  > Manage > Services and Applications > services >
    (one of the above, then) :: [scroll down to 'Windows Audio'] > r-click 'properties', general tab, set the start-up type to manual (in the dropdown), and click the start button on the next line.

  • Play audio/video/swf/flv in jsp

    Hi All,
    I am working on education site. I have a following requirement.
    1>User will search the educational resource
    2>Application will provide available resource list . Resource will be any of the following.
    a>video
    b>audio
    c>pdf/doc
    e>flv/swf
    3>User will click on any of the resource and then application will play/load the resource in iframe or in popup .
    Question: 1>How can we play audio/video/flv in jsp?
    2>If the resource is pdf/doc then how to open in iframe so that user can read only?

    "Update" to 11.5?
    Considering that 11.5 was last updated more than a year ago... that's hardly an update.
    You should be using the latest Flash Player:
    Flash Player 12.0.0.70 for ActiveX (Internet Explorer)
    Flash Player 12.0.0.70 Plug-in (All other browsers)
    Flash Player 12.0.0.70 Plug-in (Mac OS X)

  • Load and Play audio file (either sound or music) from my computer using DirectSound in C++

    #include "stdafx.h"
    #include <dsound.h>
    class AudioPlayer
    private:
    unsigned long long start_point,
    playback_point,
    break_point;
    bool now_playing, loop, ignore_start_point;
    int speed;
    //and any data that stores an audio (can be either sound or music)
    public:
    void Play_or_Resume(); //Either starts playing or resumes the audio stored in private (Runs a thread that either increments or decrements the playback_point by the speed member and sets the now_playing member to true).
    void Pause(); //Stops playing the audio stored in private until Play_or_Resume method is called (Just suspends the thread that was mentioned above and sets the now_playing member to false).
    void Play(unsigned long long from = 0, unsigned long long length = -1, bool move_start_point_too = true);
    //Plays audio from the value of the 'from' parameter along the value of the 'length' parameter and sets the now_playing member to true.
    //Playback point is pushed to the value of the 'from' parameter, and break point is pushed to the result of from + length.
    //If move_start_point_too parameter is true, then also start point is pushed where playback point is pushed too (to the value of the 'from' parameter).
    //Also the value of the 'from' parameter is an absolute position, but otherwise (if move_start_point_too parameter is false) it ('from' parameter) is relative to start point's position until it (start point) is ignored.
    //The value of the 'from' parameter never can be negative!
    void MovePlaybackPoint(unsigned long long new_position); //Modifies playback point position that is stored in private to a new position that indicates to sample no. new_position.
    unsigned long long GetPlaybackPointPosition(); //Returns playback point's position that has been alreadyS mentiond above.
    unsigned long long GetLength(); //Returns total number of samples in the audio stored in private.
    void MoveBreakPointTo(unsigned long long new_position); //Moves the break point to a new position that indicates to sample no. new position.
    //If the loop member is false, then audio should always stops playing and also set the now_playing member to false, when playback point reaches the break point, even the Pause method was not called.
    //Then calling again the Play_or_Resume method will bring the playback point back to start point (the default value for this member is zero 0).
    //But if the loop member is true, then playback point just returns to start point immediately and continue playing from there (now_playing remains true and it's value is unchanged).
    //There is a possibility to move the break point to a negative integer, so audio either stops and sets now_playing to false or replays from start point and left now_playing true according to the loop member, at the end of the audio. The default value of break point member is minus one -1 .
    unsigned long long GetBreakpointPosition(); //Returns the position of the break point that has been already mentioned above.
    void MoveStartPointTo(unsigned long long new_position); //Moves the start point to a new position that indicates to sample no. new position.
    unsigned long long GetStartPointPosition(); //Returns the position of the start point that has been already mentioned above.
    void EnableRepeatMode(); //Sets the private loop member to true.
    void DisableRepeatMode(); //Sets the private loop member to false.
    void ToggleRepeatMode(); //If loop was true before calling this function, so after it is false. Otherwrise it is true.
    bool IsRepeating(); //Returns whether audio repeats itself (from start point to either breakpoint or end of buffer). This function just returns the value of the loop member.
    void SetSpeed(int num_sam_per_sec); //Modifies the number of samples that are played in every second.
    //If number (integer) is negative, then audio is played in backward.
    //When playback point reaches start point, then it is transferred to break point if it's position is not negative. Otherwise it is transferred to the end of the audio buffer.
    void IgnoreStartPoint(); //Sets the ignore_start_point member to true. Then all methods always relate to start point as zero (even if it's value is not zero).
    void ReferStartPoint(); //Sets the ignore_start_point member to false.
    bool IsStartPointIgnored(); //Returns whether start point is ignored or not. This method just returns the value of ignore_start_point member.
    int GetSpeed(); //Returns the number of samples that are played in every second.
    void SetNumberOfChannels(byte new_value); //Modifies number of channels.
    byte GetNumberOfChannels(); //Returns number of channels.
    void SetBlockAlign(byte new_value); //Sets block align.
    byte GetBlockAlign(); //Returns block align.
    const char* LoadAudioFromComputer(const char* path_and_name_of_file, AudioPlayer* lpAp, bool auto_start_playing = true);
    //This function fills the instance pointed by 'lpAp' parameter with the data of the audio file redirected by 'path_and_name_of_file' parameter, and calls the Play_or_Resume method of this instance if auto_start_playing is true.
    //If the function succeeds, then it returns "succeed". Otherwise (if the function fails) then it returns an error string that describes the problem (the reason it failed). It can be sent to output, so it can be read, by either call to MessageBox, printf, std::cout, TextOut, DrawText functions and etc.
    //The function can fails, because the file was not exist, or could not be opened for reading, because it was opened by another process, or the file was either encrypted or protected, or corrupted, or was not audio file, but text, image and etc.
    I want to implement all methods of the AudioPlayer class and the LoadAudioFromComputer function by myself using DirectSound (the <dsound.h>) and all functions, interfaces, methods, structures, etc... that this header provides, but I don't know how! I
    need your help! This is difficult for me to find in the internet the information I need to do this. MSDN is teaching all this stuff, but this is too difficult! I need you to implement all these methods of the AudioPlayer class and the LoadAudioFromComputer
    function for me using DirectSound and the <dsound.h> and the explanations I wrote in comments, and then post the code. I will copy it to mine and read it all to learn. Please use comments so I can understand. I will thank and appreciate anyone who will
    donate his time to help me and do this for me! :D

    Microsoft pulled the plug on DirectSound HAL in Vista due to lack of hardware support. The SAL exists for
    software compatibility, good intention but bad performance as there is no longer a direct path from
    DirectSound to audio drivers.
    People choose DirectSound for its Direct-ness
    but there is no reason to choose it now.
    DirectX SDK was integrated
    with WIndows SDK which ships with Visual Studio 2012 so you don't need additional downloads for
    WASAPI and XAudio 2.
    Just look up the documentation for headers/librarieslike every other Windows API you use. If you have a hard time to find the documentation then you need to go to search engines and find search engine tutorials. 
    There are plenty of samples for both WASAPI and XAudio 2, both in the Windows SDK and online. The DirectX team has some suggestions on which to use on their team blog.
    You can find experts for those APIs at the Windows Desktop Pro-Audio Application Development forum and the
    Audio/XACT forum on MSDN (link left out for you to practice your search skills). Again, it is fine to ask for hints but don't ask the whole
    solution. You are competing with others who just need a hint to finish work here. The time spent on working on your assignment would be better spent on helping on giving hints to others. 
    Visual C++ MVP

  • Play audio in Finder?

    In OS 10.4, I could play an audio file in a column view Finder window. In 10.5, I only get some goofy generic icon. What happened? How can I get OS 10.5 to play audio files in the Finder window like 10.4 did? If there is no preference setting that will enable this, maybe someone knows of a plug-in that will restore this useful feature to the more "advanced" Leopard.

    That opens a huge dark window much larger than the slim QuickTime window
    So make it smaller. Click drag the bottom right corner.
    so it is much less interesting to me than playing in the already open Finder window.
    Select the item then in the last column with the info for that item, click the icon. I you move teh mouse over the icon, you should see a Play button (right pointing triangle).
    Or as stated, much easier, press the Space bar.
    QuickLook is designed so you can easily see what an item is without opening an application.
    It displays just about anything. Emails, movies, text docs, pdfs, etc.
    A Finder window will not let you read any text or see a movie to see specifically what the file is.
    Back to my question: Does anyone know how to enable the Finder to play sound files instead of Quicklook?
    After you select the item, click the icon in the last column.

  • Premiere pro won't display or play audio on Mac os 10.9

    premiere pro won't display or play audio on Mac os 10.9; we are uploading AVCHD mts file format video clips from a Canon camcorder. we get message : "Dolby Audio licensing decode restriction."

    next link says After Effects, but check YOUR permissions !!!
    -http://blogs.adobe.com/aftereffects/2014/06/permissions-mac-os-start-adobe-applications.ht ml
    -Mac 10.9.4 and OpenCL issue https://forums.adobe.com/thread/1514717
    -Mac 10.9.3 workaround https://forums.adobe.com/thread/1489922
    -more Mac 10.9.3 https://forums.adobe.com/thread/1491469
    -and https://forums.adobe.com/thread/1507936

Maybe you are looking for

  • IMPORTING FOOTAGE INTO FCE AND MERGING FILES WITH FINAL CUT STUDIO

    So I recently purchased Final Cut Express to create off-line, rough cut projects...to be completed by more qualified editors other than myself. But I want to make sure that Final Cut Express is the right system for me. Here are my questions: 1.) I wi

  • IPod suddenly crashing iTunes

    My trusty 30 GB iPod is suddenly crashing iTunes. As soon as I select my iPod under Devices, it crashes iTunes within 3 seconds. I have never had this issue. I'm on a Mac, OS X 10.7.3 I have reset the iPod in every possible way, wiped off all podcast

  • PIM does not connect to ACD (Does not active - stays idle)

    Situation: PIM does not activate.  Center took a power hit -  PG took a hit and had mother board replaced. After that the PIM attempts to connect but is continuously disconnedted: SPECS: PG (ver 6.0) running on a windows 2000 box              CRT cab

  • Changing mail domain name OCS 10.1.2

    I can't receive mail in OCS and think I need to alter my domain name so it will work on this test box and not interfere with the mail to our main campus domain mailserver. I downloaded the 10.1.2 Linux software and installed for a trial demo against

  • ABAP program(SE38) documentation

    Dear all, I've save/create the abap program documentation via SE38, radiobutton "Documentation". Right now, i need to know where does the text being stored. I did try on the STXH (FM READ_TEXT) but not success. Please comment. Thanks in advance.