Results 1 to 6 of 6
  1. #1
    mbarandao is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default Writing sound file to mysql

    Hello:

    I have an applet that records sound from the client machine. I want to be able to save this sound clip --which is 10 secs--to mysql db. Additionally, the applet provides the user the option of playing back that sound (after it is recorded), I need to be able to perform this task as well. All of this happens within the same session.

    Currently, the applet records the sound and saves on the user's desktop; for security resons, I want to avoid this process and write the file back to my server's db (same server serving up the applet).

    Any guidance in this area is of great help;
    Thanks

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    Is the Applet connecting directly to the db?

    If so then a straight JDBC PreparedStatement, using the setBinaryStream() to set the right field, passing in whatever stream is provided by your audio framework...presumably there's one that you use for writing out to the file currently.

  4. #4
    mbarandao is offline Member
    Join Date
    Sep 2010
    Posts
    11
    Rep Power
    0

    Default

    I' m writing wav files.

    Concerning Tolls' suggestion, if I want to avoid exposing mysql connection information when going directly from Applet to db, is there another option using some sort of php script and allowing this script to process this procedure with mysql?

    For my current code to writeToFile, I have the following:

    Java Code:
    void writeToFile() throws IOException {
           
            long lLengthInFrames = totalCount / format.getFrameSize();
            PipedOutputStream pos = new PipedOutputStream();
            PipedInputStream ios = new PipedInputStream(pos);
            AudioInputStream ais = new AudioInputStream(ios, format, lLengthInFrames);
            WriterThread thread = new WriterThread(ais, "WriteThread", outname);
            thread.start();
            
            osOut.writeTo(pos);
            
            try {
                thread.join();
            } catch (java.lang.InterruptedException e) {
                System.err.println(e);
            }
            
        }
    Any thoughts any of this?
    Last edited by mbarandao; 10-14-2010 at 03:40 PM. Reason: detailed response

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    In such situations what I'm doing is use of separate service to ftp relevant files, and avoid the overhead from the client side. It could in different models, like windows service, etc...

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    Send the file as an attachment?
    You should then be able to simply call the php script like that.

    Hunt around in the Http stuff for Java....there's stuff on here about it, but it's 4 years old. There may be a package (HttpClient?) that does most of this for you.

    Basically rolling your own http request as if it came from a browser, with multipart file stuff. Then on the server you can use whatever technology you are used to to accept the file and store it on the db.

Similar Threads

  1. Use URL to get sound file?
    By Addez in forum New To Java
    Replies: 6
    Last Post: 09-21-2010, 07:39 PM
  2. AudioClip: Sound file format?
    By CoderMan in forum Java Applets
    Replies: 3
    Last Post: 07-04-2010, 12:29 AM
  3. Sound file player
    By yourdaddy in forum NetBeans
    Replies: 9
    Last Post: 05-25-2010, 03:36 AM
  4. Replies: 1
    Last Post: 02-27-2010, 01:29 AM
  5. uploading sound file in java
    By po0oker in forum Advanced Java
    Replies: 8
    Last Post: 11-03-2007, 11:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •