need to play .wav file (attached to a voicemail) in a device with Android 4.3.1 (API 18) installed.
I am aware that there are some app like 'remote wav' that are able to play .wav file however I need to make this inbuilt feature for my app.
any help will be really appreciated; perhaps what I am looking for is to find out if there is a library to play .wav via default android Mediaplayer class or even first to convert it to any other format then play it ...
thanks for time in advance
I tried this:
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 does not work, I got
11-26 16:31:14.019 7971-7971 W/SoundPool: sample 1 not READY
I think this type of wav (attached to voicemails) is different type and can not be handle by Mediaplayer/SoundPool. see https://www.onsip.com/blog/free-way-to-listen-to-wav-files-on-your-android-device I can attach the file (sample.wav) so you can try if you want.
edited: ------------------------ as Philip Sander suggested I tried Soundpool sample not ready but none of the replied answers worked for me (no sound output)
edited:-------------------------- I applied AudioTrack approach explained Using AudioTrack in Android to play a WAV file but the result was some statics noises (white noises only for few seconds) then I applied Android AudioTrack playing .wav file, getting only white noise , this asn this to fix the statics noise, however no luck, I am running out of idea and really appreciate new ones, this is a link to a sample wav file here