Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Getting TinySound to play .oggs in a .jar  (Read 10772 times)
0 Members and 1 Guest are viewing this topic.
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Posted 2015-05-10 20:56:08 »

Okay, so I've managed to get it playing .oggs inside eclipse, but it refuses to play .oggs when it's in a jar setting. .wavs seem to work inside a .jar, but they are extremely inefficient and take up too much space.

Any ideas?
Offline philfrei
« Reply #1 - Posted 2015-05-10 21:47:16 »

when you make the jar, are you adding another level of compression to the oggs? This *might* have an effect. I haven't tried to do this in a long time, so I am only guessing.

If you are using exactly the same code and file locations and wav works and oggs don't, the only other thing I can think is that maybe needed library files aren't getting included in the jar. I can't recall if TinySound includes the needed files for ogg or if they are an additional import that is needed.

Is there an error message when the sound should play (when the jar is run from a command line)?

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #2 - Posted 2015-05-11 02:21:17 »

when you make the jar, are you adding another level of compression to the oggs? This *might* have an effect. I haven't tried to do this in a long time, so I am only guessing.

If you are using exactly the same code and file locations and wav works and oggs don't, the only other thing I can think is that maybe needed library files aren't getting included in the jar. I can't recall if TinySound includes the needed files for ogg or if they are an additional import that is needed.

Is there an error message when the sound should play (when the jar is run from a command line)?

How do I run it from a command line?

Anyways, TinySound only runs .oggs if I hook up the needed libraries by using "Build Path". These librarues are JOrbis, Tritonus_Share and Vorbisspi.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2015-05-11 17:59:06 »

The command for running a jar is as follows:
1  
java -jar fileName.jar

where fileName.jar is the name of your jar file. If Java throws any exceptions, they should show up as output on the console output unless you wrote code to catch and ignore them.

music and music apps: http://adonax.com
Offline Riven
Administrator

« JGO Overlord »


Medals: 1313
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2015-05-11 18:25:21 »

when you make the jar, are you adding another level of compression to the oggs? This *might* have an effect.
It most certainly will not break anything. Worst case would be that the GZ compressed OGG will have grown a tad in size.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline kevglass

« JGO Spiffy Duke »


Medals: 319
Projects: 25
Exp: 22 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2015-05-11 18:29:21 »

Could you post the code you're using to load them?

Kev

Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #6 - Posted 2015-05-11 20:53:25 »

Could you post the code you're using to load them?

Kev

Surething.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
///sound initialization start///
      TinySound.init();
      System.out.println("Loading music...");
      ///music///
      Music debugmenu = TinySound.loadMusic("/resources/sound/music/debugmenu.ogg");
      Music gameover = TinySound.loadMusic("/resources/sound/music/gameover.ogg");
      Music maintheme = TinySound.loadMusic("/resources/sound/music/maintheme.ogg");
      Music win = TinySound.loadMusic("/resources/sound/music/win.ogg");
      ///music end///
      System.out.println("Music loaded successfully...");
     
      System.out.println("Loading SFX...");
      ///sfx///
      //companions//
      Sound dogb = TinySound.loadSound("/resources/sound/sfx/companions/dogb.wav"); //needs to be converted to .ogg
      System.out.println("Companions SFX loaded...");
      //fight sfx//
      Sound swordsh = TinySound.loadSound("/resources/sound/sfx/fighting/sword_sheath.wav"); //needs to be converted to .ogg
      Sound swordst = TinySound.loadSound("/resources/sound/sfx/fighting/sword_strike.wav"); //needs to be converted to .ogg
      System.out.println("Fight SFX loaded...");
      //merchant sfx//
      Sound coins = TinySound.loadSound("/resources/sound/sfx/merchants/coins.wav"); //needs to be converted to .ogg
      System.out.println("Merchant SFX loaded...");
      //player sfx//
      Sound dpotion = TinySound.loadSound("/resources/sound/sfx/human/drinkpotion.wav"); //needs to be converted to .ogg
      Sound inventory = TinySound.loadSound("/resources/sound/sfx/human/inventory.wav"); //needs to be converted to .ogg
      Sound potions = TinySound.loadSound("/resources/sound/sfx/human/potions.wav"); //needs to be converted to .ogg
      Sound run = TinySound.loadSound("/resources/sound/sfx/human/running.wav"); //needs to be converted to .ogg
      Sound walk = TinySound.loadSound("/resources/sound/sfx/human/walking.wav"); //needs to be converted to .ogg
      System.out.println("Player SFX loaded...");
      //status effects//
      Sound explosionsfx = TinySound.loadSound("/resources/sound/sfx/slimes/voltaicexplode.wav"); //needs to be converted to .ogg
      System.out.println("Status effects SFX loaded...");
      ///sfx end///
      System.out.println("SFX loaded successfully...");
     
      System.out.println("Loading voices...");  
      ///voices///
      //remir//
      Sound remirfail = TinySound.loadSound("/resources/sound/voices/remir/remirfail.ogg");
      Sound remirintro = TinySound.loadSound("/resources/sound/voices/remir/remirintro.ogg");
      Sound remirnogold = TinySound.loadSound("/resources/sound/voices/remir/remirnogold.ogg");
      Sound remirthanks = TinySound.loadSound("/resources/sound/voices/remir/remirthanks.ogg");
      Sound remirstolen = TinySound.loadSound("/resources/sound/voices/remir/remirstolen.ogg");
      System.out.println("Remir voices loaded...");
      ///sound initialization end///
      System.out.println("Sound initialized successfully...");
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #7 - Posted 2015-05-11 20:58:57 »

During compiling, Eclipse throws out the "Could not find main method from given launch configuration."
Offline philfrei
« Reply #8 - Posted 2015-05-12 18:47:42 »

During compiling, Eclipse throws out the "Could not find main method from given launch configuration."

Before, you said the program runs fine in Eclipse. Is this a new error? Is this a warning that occurs when you try to run the program (but the program still runs)?

Or is this a message that occurs when you make the jar file?

Have you done anything custom or special to configure how this program is built or what it calls when it is run?

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #9 - Posted 2015-05-12 23:01:35 »

During compiling, Eclipse throws out the "Could not find main method from given launch configuration."

Before, you said the program runs fine in Eclipse. Is this a new error? Is this a warning that occurs when you try to run the program (but the program still runs)?

Or is this a message that occurs when you make the jar file?

Have you done anything custom or special to configure how this program is built or what it calls when it is run?


This error happens when I make the .jar file. And as far as I am aware, I have done nothing custom to the program. (Aside from using BuildPath to hook it up to the libraries.)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #10 - Posted 2015-05-12 23:03:53 »

It means your launch/run configuration is incorrect. Make sure you're specifying the correct one in the jar wizard.
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #11 - Posted 2015-05-15 03:14:16 »

It means your launch/run configuration is incorrect. Make sure you're specifying the correct one in the jar wizard.

Im using the default configuration, which was working fine with .wavs
Offline philfrei
« Reply #12 - Posted 2015-05-15 17:58:17 »

It means your launch/run configuration is incorrect. Make sure you're specifying the correct one in the jar wizard.

Im using the default configuration, which was working fine with .wavs

The only suggestion I can think of at this point is to try remaking the program as small as possible while still generating the error. At some point it the answer will either become clear, or you'll have posted code that we can use to recreate the error (if the error is in the code and not in Eclipse settings).

I'm assuming the error game up while making the Jar, not while running the jar. When you run the jar from the console, is there a useful error message?

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #13 - Posted 2015-05-15 21:10:12 »

Im using the default configuration, which was working fine with .wavs

The only suggestion I can think of at this point is to try remaking the program as small as possible while still generating the error. At some point it the answer will either become clear, or you'll have posted code that we can use to recreate the error (if the error is in the code and not in Eclipse settings).

I'm assuming the error game up while making the Jar, not while running the jar. When you run the jar from the console, is there a useful error message?

1  
Error: Unable to access jarfile SlimeFighter 4.jar
Offline philfrei
« Reply #14 - Posted 2015-05-15 21:54:42 »

When you ran the command

1  
java -jar SlimeFighter4.jar


the jar file was in the same directory, yes? If it is not in the same directory, then the address has to be included with the name. My apologies if I am indicating something that you already know.

Also, I'm not sure on naming conventions, and if Windows is okay with having a space in the name. Seems to me that it is safer to eliminate spaces.

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #15 - Posted 2015-05-17 23:42:35 »

When you ran the command

1  
java -jar SlimeFighter4.jar


the jar file was in the same directory, yes? If it is not in the same directory, then the address has to be included with the name. My apologies if I am indicating something that you already know.

Also, I'm not sure on naming conventions, and if Windows is okay with having a space in the name. Seems to me that it is safer to eliminate spaces.

I went and moved it into C:\ and then ran
1  
java -jar "C:\SlimeFighter 4.jar"


I got the exact same error.
Offline philfrei
« Reply #16 - Posted 2015-05-18 00:57:13 »

The name of the file has to be exactly right, including case. If your file is "SlimeFighter 4.JAR" and you specify "SlimeFighter 4.jar" it will give you the "unable to access" error message. Also, "Slimefighter 4.JAR" will fail.

Maybe it would be good to just save a "HelloWorld" program as a jar and run it from the command line, if you have never done this before. It's a crucial skill to be able to troubleshoot: e.g., make simpler cases to try and isolate where a problem lies.

Just now, I took a file of mine which uses Java audio and renamed it to include a space in the name. The original file is Tanpura.jar, and the copy is "Tanpura 1.jar".

These commands worked just fine:
1  
2  
java -jar Tanpura.jar
java -jar "Tanpura 1.jar"
So the problem is probably not due to the space in the name. Having a space in the name still makes me uneasy, though. For example, the easy-to-make error of forgetting to include the "" marks gives the following:
1  
Error: Unable to access jarfile Tanpura

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #17 - Posted 2015-05-18 22:45:21 »

The name of the file has to be exactly right, including case. If your file is "SlimeFighter 4.JAR" and you specify "SlimeFighter 4.jar" it will give you the "unable to access" error message. Also, "Slimefighter 4.JAR" will fail.

Maybe it would be good to just save a "HelloWorld" program as a jar and run it from the command line, if you have never done this before. It's a crucial skill to be able to troubleshoot: e.g., make simpler cases to try and isolate where a problem lies.

Just now, I took a file of mine which uses Java audio and renamed it to include a space in the name. The original file is Tanpura.jar, and the copy is "Tanpura 1.jar".

These commands worked just fine:
1  
2  
java -jar Tanpura.jar
java -jar "Tanpura 1.jar"
So the problem is probably not due to the space in the name. Having a space in the name still makes me uneasy, though. For example, the easy-to-make error of forgetting to include the "" marks gives the following:
1  
Error: Unable to access jarfile Tanpura


I've removed the space and ran the command java -jar SlimeFighter4.jar and the same error popped up.

Maybe I should stick to using .wavs
Offline philfrei
« Reply #18 - Posted 2015-05-19 00:38:39 »

IF you get the following result:
(1) jar with wavs plays from console with no errors
(2) exactly the same jar with oggs for wavs (from console) has an error message,
THEN we should have a basis for getting to the root of this mystery.

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #19 - Posted 2015-05-20 01:20:23 »

IF you get the following result:
(1) jar with wavs plays from console with no errors
(2) exactly the same jar with oggs for wavs (from console) has an error message,
THEN we should have a basis for getting to the root of this mystery.

I'm guessing that the issue is with the libraries not hooking up and Java getting confused as to what the main class is. However, as far as I know, the only main class is the one I set up. In Eclipse, where I've hooked up the libraries using BuildPath, everything compiles correctly.
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #20 - Posted 2015-05-26 19:29:58 »

IF you get the following result:
(1) jar with wavs plays from console with no errors
(2) exactly the same jar with oggs for wavs (from console) has an error message,
THEN we should have a basis for getting to the root of this mystery.

http://www.java-gaming.org/index.php?topic=31519.0

They seem to be having a similar problem.
Offline philfrei
« Reply #21 - Posted 2015-05-26 22:23:40 »

Notice a few things:
1) The first thing I asked him was to show the file structure and the location of the audio files.
2) He never provided this in the thread.
3) In the end, it turned out to be a problem with the addresses in the code not matching the file structure.
4) He apologized to Finn and indicated the problem was NOT with the TinySound library.

Meanwhile, I will continue to wait for the results of the example test I requested. This would be the most helpful thing to me for further troubleshooting.

music and music apps: http://adonax.com
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #22 - Posted 2015-05-26 23:26:24 »

Seems to work for me:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
import kuusisto.tinysound.*;

public class TSDemo {
   
   public static void main(String[] args) throws InterruptedException {
      TinySound.init();
     
      // sound.ogg in the 'res' folder, which is marked with 'Use as Source Folder' in eclipse
      System.out.println(TSDemo.class.getResource("sound.ogg"));
      Sound sound = TinySound.loadSound(TSDemo.class.getResource("sound.ogg"));
     
      sound.play(.5);
     
      Thread.sleep(2000);
     
      sound.unload();
      TinySound.shutdown();
   }
}




Built jar with 'Package required libraries into generated jar', but 'Extract' also tested and works.

Jar: https://drive.google.com/file/d/0Bzh2MqKbnEmcYUM2M05rY0Z0RjA/view?usp=sharing

I don't know if all the libs are required, didn't check.
It is annoying though that TS doesn't let you give it anything besides Strings or URLs, like InputStreams. Someone make a pull request!  Pointing
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #23 - Posted 2015-05-28 14:08:00 »

Notice a few things:
1) The first thing I asked him was to show the file structure and the location of the audio files.
2) He never provided this in the thread.
3) In the end, it turned out to be a problem with the addresses in the code not matching the file structure.
4) He apologized to Finn and indicated the problem was NOT with the TinySound library.

Meanwhile, I will continue to wait for the results of the example test I requested. This would be the most helpful thing to me for further troubleshooting.

I was finally able to get something to show up in the cmd.exe.

"no main manifest attribute, in C:\LWP2.jar"

It should also be noted that I changed a few things from last time. Instead of extracting the tinysound.zip in the src folder, I grabbed the .jar instead and put it alongside the other libraries, then hooked it up using buildpath.
Offline philfrei
« Reply #24 - Posted 2015-05-28 15:03:27 »

A search on an error message often turns up good information. I searched on "no main manifest attribute" (used quotes in the search) and the following links look helpful.

overview
http://javarevisited.blogspot.com/2013/01/how-to-fix-failed-to-load-main-class-manifest-attribute-jar-java-eclipse.html

some specific scenarios and solutions
http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute

The third answer in the StackOverflow link involves an Eclipse step I take for granted. If you were able to make a Jar and run it using .wav files instead of .ogg files, we would know this wasn't the problem. I'm still not clear if you are able to get a jar to run with the only difference being the use of .wav files instead of .ogg.

music and music apps: http://adonax.com
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #25 - Posted 2015-05-28 15:04:37 »

A search on an error message often turns up good information. I searched on "no main manifest attribute" (used quotes in the search) and the following links look helpful.

overview
http://javarevisited.blogspot.com/2013/01/how-to-fix-failed-to-load-main-class-manifest-attribute-jar-java-eclipse.html

some specific scenarios and solutions
http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute

The third answer in the StackOverflow link involves an Eclipse step I take for granted. If you were able to make a Jar and run it using .wav files instead of .ogg files, we would know this wasn't the problem. I'm still not clear if you are able to get a jar to run with the only difference being the use of .wav files instead of .ogg.

All of the libraries work inside the eclipse compiler, so I think the problem occurs during export to a .jar.
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #26 - Posted 2015-05-28 15:06:18 »

The inside of MANIFEST.MF:

1  
2  
3  
4  
Manifest-Version: 1.0
Rsrc-Class-Path: ./ jorbis-0.0.17.jar tritonus_share.jar vorbisspi1.0.
 3.jar tinysound-1.1.1.jar
Class-Path: .

Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #27 - Posted 2015-05-28 15:44:43 »

I was able to get it running inside the CMD, sort of. I ran it by inputting a classpath into the run command.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
Exception in thread "main" java.lang.NoClassDefFoundError: kuusisto/tinysound/TinySound at lwp2.LWP2_MAIN.main<LWP2_MAIN.java:92>

Caused by: java.lang.ClassNotFoundException: kuusisto.tinysound.TinySound
at java.net.URLClassLoader$1.run<Unknown Source>
at java.net.URLClassLoader$1.run<Unknown Source>
at java.security.AccessController.doPriveleged<Native Method>
at java.net.URLClassLoader.findClass<Unknown Source>
at java.lang.ClassLoader.loadClass<Unknown Source>
at sun.misc.Launcher$AppClassLoader.loadClass<Unknown Source>
at java.lang.ClassLoader.loadClass<Unkown Source>
... 1 more


I should probably include something about what's on line 92.

1  
TinySound.init();


EDIT: Fixed a spelling error in the error log.
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #28 - Posted 2015-05-28 16:12:26 »

I've edited the Meta-Inf and corrected it, so now it can run normally using java -jar C:/LWP2.jar

1  
2  
3  
4  
5  
Main-Class: lwp2.LWP2_MAIN
Manifest-Version: 1.0
Rsrc-Class-Path: ./ jorbis-0.0.17.jar tritonus_share.jar vorbisspi1.0.
 3.jar tinysound-1.1.1.jar
Class-Path: lwp2.LWP2_MAIN


The same error still pops up though.
Offline Vulpicula

Senior Newbie


Exp: 7-9 months



« Reply #29 - Posted 2015-05-29 20:25:54 »

Sorry for all the post spam, but after I removed the tinysound .jar and replaced it by putting the "Tinysound-Master.zip" files in the src, a different outcome happened.

It instead popped up with a large amount of "Unsupported audio resource! could not get audio stream from input URL" messages.

Edit: It's been fixed. The error was a corrupt .metadata file.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
Ecumene (49 views)
2017-09-30 02:57:34

theagentd (74 views)
2017-09-26 18:23:31

cybrmynd (183 views)
2017-08-02 12:28:51

cybrmynd (181 views)
2017-08-02 12:19:43

cybrmynd (188 views)
2017-08-02 12:18:09

Sralse (195 views)
2017-07-25 17:13:48

Archive (745 views)
2017-04-27 17:45:51

buddyBro (878 views)
2017-04-05 03:38:00

CopyableCougar4 (1428 views)
2017-03-24 15:39:42

theagentd (1317 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!