This is part of an ongoing series of posts about Homesick, my bachelor project.
The Android side of the client is hosted here.
Last post, I set up a button in my app to record and store audio. This time, I’ve set up a play button that will play the audio I recorded.
Once again, the official API guides from Google were very helpful.
The code is very similar to that of recording audio, from last post:
1 2 3 4 5 6 7 8 9 10
First, we instantiate an object of type android.media.MediaPlayer. This object will be in charge of playing audio we’ve recorded. In the next line, its data source is set to the audio file at the path we recorded to. This means that the player will play this file.
Finally, it’s prepared to start playing and start() is called on it to start playing. Simple!
Pressing the Play button again will stop:
1 2 3 4
That’s it! Now I have a simple prototype that records and plays audio on Android.