2

This type of wav file (32bit float 8000hz mono) which is attached to voicemails, is different type and can not be handle by Mediaplayer/SoundPool. see this link here is a link to a similar sample.wav file so you can try it yourself if you want.(it is wav 32 bit float 11025hz mono)


my first attempt was to play it via mediaPlayer but it throw a NullPointerException: here is log cat :

 - 11-26 16:37:14.969 20287-20287 E/AndroidRuntime: FATAL EXCEPTION:main
 - 11-26 16:37:14.969 20287-20287 E/AndroidRuntime:
   java.lang.NullPointerException 
 - 11-26 16:37:14.969 20287-20287 E/AndroidRuntime: at   
   com.example.bastamib.wavplayer.MainActivity$2.onClick(MainActivity.java:38)

Then I used SoundPool :

public class MainActivity extends Activity {
    SoundPool mPlayer;
    int mSoundId ;
    Button play1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mPlayer = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
        mSoundId = mPlayer.load(this, R.raw.s2, 1);
        Button play1 = (Button) this.findViewById(R.id.buttonPlay1);
        play1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                mPlayer.play(mSoundId, 0.99f, 0.99f, 0, 0, 1f);
            }
        });
    }
}

but did not work, I got

11-26 16:31:14.019 7971-7971 W/SoundPool:   sample 1 not READY

to fix

sample 1 not READY

I tried Soundpool sample not ready but none of the replied answers including the selected answer worked for me (basically no sound output)


Then I moved to AudioTrack solution: explained here Using AudioTrack in Android to play a WAV file

result was some static noises ! not interesting at all ! pifff


to fix that I applied Android AudioTrack playing .wav file, getting only white noise but no luck applied all answers there and still getting statics noises.

and Here I am stuck ! any help will be appreciated.

a side note : I am aware that there are some app like 'remote wav' that are able to play VOIP .wav file however I need to make this inbuilt feature for my app.

Community
  • 1
  • 1
bastami82
  • 3,979
  • 5
  • 28
  • 38

0 Answers0