AssertManager - Loading audio file from a location outside the classpath

Hi,

I want to load an audio file from a location not in class path. When I tried to do that, AssertManager throws an exception saying that assert is not found. But it is in the location.

Is there any way to load the files not in class path using existing AssertManger ?



Thanks,

Kasun.

Yes, after getting an idea by looking at the example provided for the HtppZipLocator, I registered the locator as follows. [Please correct me if I am wrong. I am not a expert in this business]

[java]assetManager.registerLocator("F:|DilviRuntime|application|audio, FileLocator.class);[/java]

I was getting the following error, that is why I thought to come to the forum and get some ones help.

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,spring-osgi-extender[1543c88]-threads]

com.jme3.asset.AssetNotFoundException: F:|DilviRuntime|application|audio|S1|1.wav (Buffer)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:236)[/java]



NOTE : | is used to display the forward slash in this post.

Ah… if you’d started there we’d be much further along. :slight_smile: That is the approach you should be taking, there is just some detail that needs to be worked out.



Note: this is a forward slash: /



DOS and windows use “back slashes” which nearly every other system in the world treats as an escape… including the forum, I think. And certainly Java does as well.



Since the message originally came through with “back slashes” in it and now has pipes but you say you replaced the “forward slashes”, I felt the need to clarify. Not just to be pedantic but because it’s important.



Can you use / forward slashes in your paths and see if that helps? Java can use forward slashes even if the operating system would normally use back slashes. And it would make posting the code easier.

Register a locator, best for the filesystem root so you can load any model.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_asset

Thanks Norman. Yes, in there it is mentioned to have the asserts in the folder structure suggested. But, I am having my sound clips on a separate location. That means,



Is it required to have all the sound clips in the folder suggested ? Or is there a way to load asserts stored out side the class path ?



Note: I am using jme as external library in my plugin project and not using the JME SDK.



Kasun.

See this section of the tutorial: “Loading Assets From Custom Paths”



Then reread Normen’s response: “Register a locator, best for the filesystem root so you can load any model.”

Thanks for you quick feed back. Ohh, yes it is back slash, I have mistaken that.



I tried the way as you have suggested. Used forward slash instead of back slash.

[java]assetManager.registerLocator("F:/DilviRuntime/application/audio", FileLocator.class);[/java]



But still I am getting the same error :frowning:



Sep 21, 2011 12:19:11 AM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,spring-osgi-extender[1543c88]-threads]

com.jme3.asset.AssetNotFoundException: F:/DilviRuntime/application/audio/S3/1.wav (Buffer)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:236)

at com.jme3.audio.AudioNode.(AudioNode.java:153)

Ok, and the presumption is that the file actually exists at that path.



Hopefully someone more familiar with the asset manager can step in at this point… it all looks right to me. And at least now we can all see the real code without a forum-specific filtering. :slight_smile:

The mistake you’re making is that you try to use the full path but you already registered the folder. So try just assetManager.loadAsset(“S3/1.wav”); thats why I said “register the filesystem root”.

Thank you Norman for correcting my mistake.