【发布时间】:2011-05-24 03:27:12
【问题描述】:
我的问题有点难以描述。
我的项目(和 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 = 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 之类的资源……但就我而言,这并不容易处理。
谢谢!
【问题讨论】:
标签: java android file path soundpool