Getting TinySound to play .oggs in a .jar

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

They seem to be having a similar problem.

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.

Seems to work for me:

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! :point:

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.

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

some specific scenarios and solutions

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.

The inside of MANIFEST.MF:

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

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

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.

TinySound.init();

EDIT: Fixed a spelling error in the error log.

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

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.

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.