我的问题有点难以描述。
我的项目(和 apk 文件)中有一个单独的资源文件夹。
String path = "/resources/instruments/data/bongo/audio/bong1.wav";
我已经可以使用它了
url = StreamHelper.class.getClassLoader().getResource( path );
url.openStream();
但实际上我想将文件加载到 SoundPool 中。我试过这样:
SoundPool soundPool = new SoundPool( 5, AudioManager.STREAM_MUSIC, 0 );
soundPool.load ( path, 1 );
...但我总是收到错误信息:“错误加载/资源...”
load(String path, int) 在这个链接上,我看到我需要正确的 File 路径
File file = new File( path );
if( file.exists() )
//always false but i thing if it would be true soundPool.load should work too
现在我的问题是:它的工作路径如何。还是对我的问题有任何其他想法(与 AssetManager 一起使用)?
顺便提一句。我知道有一些特殊的 Android 方法可以获取像 R.id.View 这样的资源......但在我的情况下,这并不容易处理。
谢谢!