0

我有一个应用程序,可以在外部存储中搜索我想要的文件。例如名为 sound1.mp3 的歌曲String path = getFullFilePath(getApplicationContext(), "sound1.mp3);。我将加载的声音用于 soundpool。我想从 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
4

1 回答 1

0

根据您的 LogCat,您存储的路径zipStr是,/mnt/sdcard

SoundPool.load需要音频文件的路径(参见文档:SoundPool.load())。

确保你zipStr的等于/mnt/sdcard/sound1.mp3.

于 2012-11-06T15:50:39.810 回答