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: