必要なファイルの外部ストレージを検索するアプリケーションがあります.sound1.mp3 という名前の曲の例.soundpool にString path = getFullFilePath(getApplicationContext(), "sound1.mp3);
ロードされたサウンドを使用します。Preference Edittext からテキストを取得し、「sound1.mp3」以外で使用したい..私はこれを試しました:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SharedPreferences getPrefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
SharedPreferences settings = getSharedPreferences("EditText",0);
String zipStr = settings.getString("ime", "");
sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
String path = getFullFilePath(getApplicationContext(), zipStr);
Log.d("ime", "Path: " + path);
mSoundId = sp.load(path, 1);
LogCat はこれを与えます:
11-06 15:57:59.169: D/ime(5688): Path: /mnt/sdcard
11-06 15:57:59.539: E/SoundPool(5688): Unable to load sample: (null)
11-06 15:58:01.149: W/asset(5688): deep redirect failure from 0x0103003e => 0x02060007, defStyleAttr=0x00000000, defStyleRes=0x00000000, style=0x00000000
11-06 15:58:17.509: W/SoundPool(5688): sample 1 not READY