can the android emulator play audio

前端 未结 1 520
走了就别回头了
走了就别回头了 2021-01-13 05:01

I wanted to record and pass through the recorded sound to the phone\'s speaker, but I could not get the recording code to work (app crashes, SEE MY ATTEMPT HERE) so I am now

相关标签:
1条回答
  • 2021-01-13 05:23

    Yes, you can do audio related work on emulator.

    Your code sequence should be -

    mp1 = new MediaPlayer();
    mp1.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mp1.setDataSource(PATH_TO_FILE);
    mp1.prepare();
    mp1.start();
    

    And for setting permissions in the manifest file.

    Use these for record feature-

    and these for playing feature -

    There is a guide article on official android developer website

    Guide to audio capture and Guide to media playback

    and if it dosn't work, then post your log cat screenshot.

    0 讨论(0)
提交回复
热议问题