Here's a question I had stumbled upon a few days ago.
问题是询问应该如何使用方法“load(String path, intpriority)”,以及“path”变量应该是什么样的语法。不幸的是,该问题的所有答案都给出了错误的答案。他们都没有提到“load(String, int)”方法的使用,甚至没有一个回答“路径”应该是什么样子。
我无法想出解决方案。有人可以帮忙吗?
最佳答案
该路径只是文件在android文件系统中的路径。
例如,如果我将 foo.mp3
拖放到我的 Android 文件系统中,它会被放置在 /mnt/sdcard/foo.mp3
我会传递 /mnt/sdcard/foo.mp3
到加载方法。
基本路径 (/mnt/sdcard/
) 可能因手机而异,因此您可以使用 Environment.getExternalStorageDirectory()
查询。
据我所知,它不能与资源一起使用,而只能与文件系统中的文件一起使用。
另外,可能应该包括来自 Android docs 的注释,这样“sdcard”就不会混淆。我的手机甚至没有外部 SD 卡,但我的 Android 文件系统中的所有文件都放在/sdcard/文件夹中,我不知道为什么。
Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.
关于java - SoundPool: "path"中的 "load(String path, int priority)"是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12480330/