user1781336
user1781336

Reputation: 85

Android play and loop audio

I'm trying to make a simple android app that plays and loops through one audio file (like white noise). I'm not sure how audio works with apps, download it to SD card? How do I do this? And how do I loop through it, until "stop" is selected?

Upvotes: 0

Views: 172

Answers (1)

FD_
FD_

Reputation: 12919

If your audio files are static, ship them in your app`s res/raw directory. This is how you can play and loop them from there:

MediaPlayer mp;
mp = MediaPlayer.create(getApplicationContext(), R.raw.yoursound);
mp.setLooping(true);
mp.start();

For stopping, just call

mp.stop();

Upvotes: 1

Related Questions