Wednesday, February 24
  • Home
  • Archive
  • Search
Valuedandloved – Trang Thông Tin Tổng Hợp Cập Nhật 24/24
  • Home
  • Du Lịch
  • Làm Đẹp
  • Sức Khoẻ
  • Thể Thao
  • Khác
    • Tin Hot
    • Âm Nhạc
    • Ẩm Thực
    • Công Nghệ
    • Game
    • Giải Trí
    • Giáo Dục
    • Phim
user avatar
sign in sign up
A password will be e-mailed to you.
Lost password Register Login

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

Avatar admin
May 23, 2020
113 views



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:

Facebook:

Instagram:

Twitter:

Blog:

Nguồn: https://valuedandloved.com

Xem thêm bài viết khác: https://valuedandloved.com/cong-nghe/

Xem thêm Bài Viết:

  • Những lưu ý khi cài đặt và sử dụng phần mềm Microsoft Toolkit
  • Hướng dẫn cách SEO Youtube lên Top 1 nhanh chóng
  • Các khu vực này đều có tỷ lệ xét nghiệm dương tính trên 3% trong bảy ngày qua
  • Chuyển đổi PDF sang Word tốt nhất: Điều gì cần xem xét?
  • Phần mềm như một dịch vụ (SaaS) là gì?
Categories: Công Nghệ

Comments (50)

  1. Angelo A.

    Can I play a song that is on dropbox?

    May 23, 2020 - 3:15 am Reply
  2. Yuval Farangi

    thank you so much!!! helps me every time!!!

    May 23, 2020 - 3:15 am Reply
  3. Abderrahim Elassaly

    Hi, i need the video's link "keep music playing when we leave our app" PLZ
    Thanks

    May 23, 2020 - 3:15 am Reply
  4. Fortunate Kidz

    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 ?

    May 23, 2020 - 3:15 am Reply
  5. SHEIKH HARIS KHALID

    How to do it using services??

    May 23, 2020 - 3:15 am Reply
  6. Kevin Li

    It freezes when I click "Play"

    May 23, 2020 - 3:15 am Reply
  7. Ravi Sorathiya

    Such a beautiful voice

    May 23, 2020 - 3:15 am Reply
  8. Ravi Sorathiya

    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

    May 23, 2020 - 3:15 am Reply
  9. tamer

    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 Type..you solved it

    May 23, 2020 - 3:15 am Reply
  10. Romit Gandhi

    I want to stream audio data from one device to another device via bluetooth and play that received audio stream in android phone, can you tell me how can I do that?

    May 23, 2020 - 3:15 am Reply
  11. Joshua Gunja

    I want to create two raw directories is it possible?

    May 23, 2020 - 3:15 am Reply
  12. Pranav Joshi

    The nice thing about these videos, in particular, is that he explains what he's doing and why. This means that it's easier to build upon this knowledge later on and allows me to be more self-sufficient. If I use anyone else, I tend to have to come back to them and re-watch the whole thing if there is something I need to draw on. But with one of these, I can easily apply this knowledge elsewhere to further improve my projects without using valuable time re-watching videos I have already watched. Thank you so much for this content and keep up the good work!

    May 23, 2020 - 3:15 am Reply
  13. Saida Parizi

    the first relaxing coding lessons in the world

    May 23, 2020 - 3:15 am Reply
  14. Viddesh K

    If anyone have error in raw then take directory and named it raw

    May 23, 2020 - 3:15 am Reply
  15. Garry Kraemer

    Outstanding tutorial! I have been trying all day to get this working! You make it look easy! Thanks from a 71 yr old, ex FORTRAN, C, ADA real-time SW engineer (B-52 & F-15C/E/S!

    May 23, 2020 - 3:15 am Reply
  16. Stephen

    i record my my own music, i create regular sound files, mp3 and wav- is there no simple way to just copy the files to my phone(which I can do now) and play them with the "music" app that came with my phone ? – I cant believe how complicated this is. the "music" app does not see or scan media files I moved onto my phone. I dont want my media files uploaded to google or spotify I just want my phone to act like an mp3 player for local files. Help? I don't want to write code to do this either

    May 23, 2020 - 3:15 am Reply
  17. นันทวัฒน์

    Thank you
    very much.

    May 23, 2020 - 3:15 am Reply
  18. Anandh Nandu

    Super Bro nice video
    And you can add the video coding Bro????

    May 23, 2020 - 3:15 am Reply
  19. Handsome TV

    hello, why do you change constraint to relative layout?

    May 23, 2020 - 3:15 am Reply
  20. Avtem

    Nothing happens when i click 'play' button, but 'stop' toast works fine

    May 23, 2020 - 3:15 am Reply
  21. Siamak Aghili

    You are the best teacher I have ever seen.

    May 23, 2020 - 3:15 am Reply
  22. A R

    @Coding in Flow Great tutorial! How can I use the speakers on the back of the smartphone?

    May 23, 2020 - 3:15 am Reply
  23. Dean Yaukey

    Your tutorial is great. Hoping you can help me get past one last hurdle. With this code I'm trying to play a 5 min song. It stops at almost exactly 1 min.

    May 23, 2020 - 3:15 am Reply
  24. Samet Yılmaz

    When i press the play button i got no sound! Please Help Me!

    May 23, 2020 - 3:15 am Reply
  25. Ismail Ghedamsi

    The channel is my main support for my android course in school

    May 23, 2020 - 3:15 am Reply
  26. Ahmed Elsayed

    Dam i love your WORK BRO
    You Great at this THINGS
    LOVE YOU

    May 23, 2020 - 3:15 am Reply
  27. shaahid khan

    hello
    bro my mp3 file has saved as text file can u help me to change the file pls !!!!

    May 23, 2020 - 3:15 am Reply
  28. HH

    Is there any problem if we use Stop method directly?

    May 23, 2020 - 3:15 am Reply
  29. biene

    cool ist nebenbei das man dem Button die Click-Funktion schon im xml-File zuweisen kann, dann braucht man nicht "umständlich" den ClickListener erstellen und zuweisen (also fast wie in C# und WPF)

    May 23, 2020 - 3:15 am Reply
  30. biene

    mega interessant, danke und thank you ;o)

    May 23, 2020 - 3:15 am Reply
  31. Ertugrul

    HI, I want to thank you for this insightful and good video. Thanks to you I just built my first App. I am an English teacher and I want to put tracks in an App. Can you also show (if you haven't done yet) switching between pages. EG

    May 23, 2020 - 3:15 am Reply
  32. ema

    could you please give me the link for the next lesson (the services)

    May 23, 2020 - 3:15 am Reply
  33. Gustavo Valery

    This is useless. You should teach people to load MediaFiles and do this actions in a Service Class.

    May 23, 2020 - 3:15 am Reply
  34. Yhamin Polo

    LOVE YOU BOY!

    May 23, 2020 - 3:15 am Reply
  35. Justin

    Thank you very much! Clear and simple, just what I needed

    May 23, 2020 - 3:15 am Reply
  36. Tsuki Shiroi

    Hi, thanks for your videos, can you please make a video about How to Play a Sound File list Using exoplayer? thanks

    May 23, 2020 - 3:15 am Reply
  37. Mukhlisin GlobalTech

    Eror:method stop in class mainactivity
    Required View
    Found no arguments
    Dll

    May 23, 2020 - 3:15 am Reply
  38. Dve Ram

    Can you do a tutorial for requesting and releasing AudioFocus?

    May 23, 2020 - 3:15 am Reply
  39. Namer Hurr

    Thanks for the video. It was very helpful!

    May 23, 2020 - 3:15 am Reply
  40. Božidar Mitrovic

    If we stop music player multiple times, isn't that going to cause NullPointerException, because MediaPlayer.create() method can return null? And if i am right, is there a way around this?

    May 23, 2020 - 3:15 am Reply
  41. hocine GUEBBAS

    you are the best. thank you man

    May 23, 2020 - 3:15 am Reply
  42. Sandeep sahu

    Sir after raw name i write music name but this is not show and get error

    May 23, 2020 - 3:15 am Reply
  43. Calamity

    Have you tried setting PlayBacKParams?

    May 23, 2020 - 3:15 am Reply
  44. jayant kumar

    Awesome video 🙂

    May 23, 2020 - 3:15 am Reply
  45. hocine GUEBBAS

    you are the best

    May 23, 2020 - 3:15 am Reply
  46. Lhex B

    When trying to play the sound, I get this E/MediaPlayer: Should have subtitle controller already set, Any help please

    May 23, 2020 - 3:15 am Reply
  47. El que quiere dar su opinion

    Ty man, this is awesome

    May 23, 2020 - 3:15 am Reply
  48. Calamity

    Can we integrate a file manager inside the app so the user with a press of a button opes up the file manager, browses and picks an audio file from the folders to be played by the MediaPlayer?

    May 23, 2020 - 3:15 am Reply
  49. sks

    how to do this with 20 different audio files in the same layout? using id on the button?

    May 23, 2020 - 3:15 am Reply
  50. Calamity

    Is there a way to set the mediaPlayer to replay the previous iteration?

    May 23, 2020 - 3:15 am Reply

Leave a reply

Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts
microsoft-toolkit-la-phan-mem-pho-bien-hien-nay

Những lưu ý khi cài đặt và sử dụng phần mềm Microsoft Toolkit

February 2, 2021
Nhắc link video trong Quora là sự lựa chọn thông minh

Hướng dẫn cách SEO Youtube lên Top 1 nhanh chóng

December 25, 2020
cac-khu-vuc-nay-deu-co-ty-le-xet-nghiem-duong-tinh-tren-3-trong-bay-ngay-qua

Các khu vực này đều có tỷ lệ xét nghiệm dương tính trên 3% trong bảy ngày qua

October 15, 2020

Chuyển đổi PDF sang Word tốt nhất: Điều gì cần xem xét?

October 7, 2020

Phần mềm như một dịch vụ (SaaS) là gì?

September 25, 2020
Tạo đám mây trong cad

Tuyệt chiêu tạo đám mây trong CAD chỉ với vài phút cực kỳ đơn giản

August 29, 2020
Related Posts
microsoft-toolkit-la-phan-mem-pho-bien-hien-nay

Những lưu ý khi cài đặt và sử dụng phần mềm Microsoft Toolkit

February 2, 2021
Nhắc link video trong Quora là sự lựa chọn thông minh

Hướng dẫn cách SEO Youtube lên Top 1 nhanh chóng

December 25, 2020
cac-khu-vuc-nay-deu-co-ty-le-xet-nghiem-duong-tinh-tren-3-trong-bay-ngay-qua

Các khu vực này đều có tỷ lệ xét nghiệm dương tính trên 3% trong bảy ngày qua

October 15, 2020

Chuyển đổi PDF sang Word tốt nhất: Điều gì cần xem xét?

October 7, 2020

Phần mềm như một dịch vụ (SaaS) là gì?

September 25, 2020
Tạo đám mây trong cad

Tuyệt chiêu tạo đám mây trong CAD chỉ với vài phút cực kỳ đơn giản

August 29, 2020
Tìm Kiếm
Xem Thêm
Gallery image with caption: Medela Swing Breast Pump Review – Babylist
Gallery image with caption: Memrise Premium APK [ January 2020 ] Download Memrise Pro APK | Memrise Mod APK 2019 |
Gallery image with caption: Adobe Media Encoder CC 2015 – How To Improve Your Workflow
Gallery image with caption: điện thoại 950k MEIZU M2 NOTE – ĐÁNH GIÁ NHANH
Gallery image with caption: Đánh giá chi tiết Meizu M6 Note : ông vua phân khúc giá 4 triệu
Lưu Trữ
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • June 2019
  • May 2019
Copyright 2020 © Valuedandloved | All Rights Reserved.
  • Liên Hệ
  • Chính Sách Bảo Mật