I prepare:

private static SoundPool soundPool; private static HashMap<Integer, Integer> soundPoolMap; soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 100); soundPoolMap = new HashMap<Integer, Integer>(3); 

How to download from the resource, I understood (line below)

  soundPoolMap.put( S1, soundPool.load(context, R.raw.s1, 1) ); 

And how to put a file from an SD card there?

I prepare the file myself as follows:

 File FileOut = new File(getExternalFilesDir(path), file_out); 

In general, the task is as follows: there are audio files (wav format) on the sd card. You need to play them in a certain order. The order will be in the form of a playlist. And yet, there should be no pauses between playing the files, i.e. one ended, immediately the other begins.

Perhaps this task can be solved without resorting to SoundPool. What do you advise?

    1 answer 1

    If nothing else helps - look at the documentation finally))) SoundPool.load(String path, int priority)

    • Does not work. I put the file: soundPoolMap.put (1, soundPool.load (FileOut.getCanonicalPath (), 1)); I run the file: soundPool.play (soundPoolMap.get (1), volume, volume, 1, 0, 1f); - kaaa
    • What exactly does not work? What mistakes? About permissions to access files are not forgotten? If the sounds are more than 5 seconds, then SoundPool does not suit you at all. And the download may take time and the play does not work right away - then you need to use SoundPool.OnLoadCompleteListener - woesss
    • there are permissions, if (soundPool == null || soundPoolMap == null) check and sounds for more than 5 seconds. Probably the duration of the problem. - kaaa
    • You have problems with the sequence of actions, since the variables are not initialized. On long tracks, he will just play the beginning (a few seconds) and that's it. Then you need to use MediaPlayer . - woesss
    • Yes, I have already switched to MediaPlayer, because Files are large and SoundPool does not fit. - kaaa