0

how can I play a mp3 file from Resources/raw in a simple player in android ? like in file preview in default file manger in android

please help me

RayanFar
  • 539
  • 11
  • 28

1 Answers1

1

You can use a MediaPlayer like this (called inside an Activity):

MediaPlayer mp = MediaPlayer.create(this, R.raw.mp3file);
mp.start();
MadEqua
  • 1,142
  • 9
  • 19
  • i want to play with a simple player with progressBar and a play/stop button – RayanFar Oct 12 '14 at 20:55
  • With the MediaPlayer class you have all the methods needed to do that. Use `getDuration()` to know the max value of the ProgressBar. With `getCurrentPosition()` you will know what's the value to put on the ProgressBar. Then you link your play and stop buttons to `start()` and `stop()`. – MadEqua Oct 12 '14 at 21:02
  • is it possible to use intent and play with default player in android? – RayanFar Oct 12 '14 at 21:04
  • Sure it is. Check this question: http://stackoverflow.com/questions/14505153/how-to-play-audio-file-from-raw-assets-folder-on-the-native-default-media-player – MadEqua Oct 12 '14 at 21:11
  • thanks i try that but i want to play the sound in a player like when we preview an Audio file in sd card ok? – RayanFar Oct 12 '14 at 21:16
  • I'm not sure about that behaviour. That depends completely on the file manager you're using. Maybe someone else will come in and help you more. – MadEqua Oct 12 '14 at 21:24