Results 1 to 6 of 6
  1. #1
    Lingerz is offline Member
    Join Date
    Sep 2009
    Posts
    21
    Rep Power
    0

    Default Packing an Application

    I'm loading sounds from a file using sun.audio. When the application's packed into a JAR file the sound doesn't play. Is a different way of packaging required or more convenient? Or is sun.audio unusable in that state?

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    How are you loading the sound? What's its path when it works VS when it doesn't?

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    When the application's packed into a JAR file the sound doesn't play
    How do you access the sound file?
    Is the sound file in the jar file or on disk?

    You should be able to put the java classes and any files it needs to read into a jar file.
    Use the getResourceAsStream() method to get a stream to read the files bytes from.

  4. #4
    Lingerz is offline Member
    Join Date
    Sep 2009
    Posts
    21
    Rep Power
    0

    Default

    I'm loading and playing via a method, 'playSound(int i)', which uses AudioStream and AudioPlayer.

    Java Code:
    sou = new AudioStream(new FileInputStream("Sounds/"+i+".au"));
    AudioPlayer.player.start(sou);

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Your code expects there to be a file in the Sounds folder on the PC because it uses the FileInputStream class.
    If you use getResourceAsStream() the sound file can be in the jar file or anywhere on the JVM's classpath.

  6. #6
    Lingerz is offline Member
    Join Date
    Sep 2009
    Posts
    21
    Rep Power
    0

Similar Threads

  1. packing java project
    By silversurfer2in in forum New To Java
    Replies: 12
    Last Post: 06-09-2010, 08:58 AM
  2. Replies: 3
    Last Post: 12-04-2009, 12:10 PM
  3. Packing vars
    By Supamagier in forum Advanced Java
    Replies: 6
    Last Post: 09-20-2008, 12:26 AM
  4. Replies: 0
    Last Post: 02-16-2008, 09:31 PM
  5. Replies: 0
    Last Post: 02-16-2008, 09:29 PM

Tags for this Thread

Posting Permissions

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