How to Play a Sound File Using the MediaPlayer Class – Android Studio Tutorial


In this video we will take a look at a simple MediaPlayer example. We will play a local sound file from our raw folder and we will be able to pause, resume and stop the music. When we stop our MediaPlayer, we will immediately release it to free up system resources.

Check out the SoundPool video:

Source code:

❗ Subscribe to the channel:

⏯ Watch more tutorials:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:






Xem thêm bài viết khác:


  1. hello everybody. Where can i find similar songs? I want to make a quiz app and I need a song for background. 🙂

  2. Hello, I'm new to this and need help to understand that release part you talked about.
    Could you help me out?

  3. Hello; I have a few buttons that play different sounds of more than 10 seconds. How can I stop playing a sound and reset it when I press on another sound button? I used your "PLAY" method to play sound files according to the buttons ID's. Thanks so much bro

  4. mine is working but the only problem is i have a long delay when executing stop button 4 to five seconds delay how can i solve the delay?

  5. can you upload a tutorial on how to increase and decrease the tempo of the song, without interrupting the playback..

  6. How do you put 2 or more songs there . When song 1 play , then I play song2 and song1 stop at that time. How to implement that ?

  7. Hey bro you Are awesom
    Please make video on how you approaches your Android development skill from the starting and about tips to become a smart developer like you

  8. Thank you, i stayed 2 days trying to figure out how to use the same instance of Media Player without creating a different instance of Media Player every time i click play or pause…even when i tried to save "Media Player " instance into firebase, i failed because of data solved it


Please enter your comment!
Please enter your name here