Play music on my Android app

Asked

Viewed 279 times

0

I’m wanting to make a list with song names , and when I click on some list item play the song. Does anyone know how to do this?

I was looking around on websites and I found this:

public void playAudio(View view){
    mp = MediaPlayer.create(this, R.raw.musica1);
    mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
        public void onCompletion(MediaPlayer mp) {
            mp.stop();
            mp.release();
            mp = null;
        }
    });
    mp.start();
}

It worked to play the song when clicking the button.

I used this R.raw.musica1 , this musica1 and the name of my song, has how I put it in a string or direct in a list?

  • Just create a Activity with the names of the songs and then call the Android playback API when one of them is "clickada". Joking aside, what you tried?

  • I want a light , because I never did anything with music on android

  • 1

    As apparently you have nothing done, try to separate your doubts. I believe that first you will need to get the list of songs to put on a ListView. But where do the songs come from? From the Android? From the app itself? From the "cloud"? Then said you move on to the second challenge that is to play this song. Anyway, it’s better to segment your doubt to make it easier, the way it is is too broad.

  • ata. the tricky for me and playing the music, I thought I’d put her in the app even in a folder on res. put on the list later I’ll see how I’ll do I’ll have to define names for the songs

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.