Frage

hi i am developing android application in which i need to play a saved mp3 voice when someone click on button. on clicking button another activity will be opened and saved voice should be played how can i do it??

Regards

War es hilfreich?

Lösung

First, you need a service to play MP3 via android.media.MediaPlayer

Second, you can put your saved MP3 in res/raw folder. (manual create it, if it doesn't exist)

And this could help : Get URI of .mp3 file stored in res/raw folder in android

......

cheers~

Andere Tipps

Here is a sample of code:

button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        int res = getResources().getIdentifier ( "yourfile", "raw","your.package.here" );
        mPlayer = MediaPlayer.create ( YourActivity.this, res );
        mPlayer.start();
    }
});

You should create a directory res/raw with the file yourfile.mp3 in it

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top