Home > Mobile >  The great spirit guide, android music player after the access to the local music I don't know h
The great spirit guide, android music player after the access to the local music I don't know h

Time:09-24

CodePudding user response:

Use MediaPlayer
 
Public void play (String path) {
Try {
MediaPlayer. Reset ();
MediaPlayer. SetDataSource (path);
MediaPlayer. PrepareAsync ();
MediaPlayer. SetOnPreparedListener (new mediaPlayer. OnPreparedListener () {
@ Override
Public void onPrepared (MediaPlayer MediaPlayer) {
MediaPlayer. Start ();
}
});
} the catch (IOException e) {
e.printStackTrace();
}
}

CodePudding user response:

reference 1st floor JMSissi response:
use MediaPlayer
 
Public void play (String path) {
Try {
MediaPlayer. Reset ();
MediaPlayer. SetDataSource (path);
MediaPlayer. PrepareAsync ();
MediaPlayer. SetOnPreparedListener (new mediaPlayer. OnPreparedListener () {
@ Override
Public void onPrepared (MediaPlayer MediaPlayer) {
MediaPlayer. Start ();
}
});
} the catch (IOException e) {
e.printStackTrace();
}
}

I added the useless ah, a great god can you help me?

CodePudding user response:

reference 1st floor JMSissi response:
use MediaPlayer
 
Public void play (String path) {
Try {
MediaPlayer. Reset ();
MediaPlayer. SetDataSource (path);
MediaPlayer. PrepareAsync ();
MediaPlayer. SetOnPreparedListener (new mediaPlayer. OnPreparedListener () {
@ Override
Public void onPrepared (MediaPlayer MediaPlayer) {
MediaPlayer. Start ();
}
});
} the catch (IOException e) {
e.printStackTrace();
}
}

I also wrote a play interface, how to click on the list of music to jump in the past? Realize the play,,,

CodePudding user response:

The baidu, hand in the past, the list that the list passed with intent

CodePudding user response:

Set list item click event, click on the click on the item you want to play music in the path to interface, all that remains is to use MediaPlayer
  • Related