Playing audio file from Sdcard

前端 未结 2 1464
花落未央
花落未央 2020-12-04 00:09

I would like to play an audio file from the sdcard. How can I read the audio file and play it? Below is my code to play audio file:

int sound1;
sound1 = mS         


        
2条回答
  •  失恋的感觉
    2020-12-04 00:31

    Use the code below it worked for me.

    MediaPlayer mp = new MediaPlayer();
    mp.setDataSource("/mnt/sdcard/yourdirectory/youraudiofile.wav");
    mp.prepare();
    mp.start();
    

提交回复
热议问题