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:
- Adobe Character Animator là gì? Top cấu hình máy tính chạy Character Animator
- Tìm hiểu CRM bất động sản và những điều cần biết
- Binary Option là gì? Giao dịch trên sàn Binary Option thực hiện như thế nào?
- Top CPU Tốt Nhất 2020 Cho Người Build PC
- Những lưu ý khi cài đặt và sử dụng phần mềm Microsoft Toolkit
Can I play a song that is on dropbox?
thank you so much!!! helps me every time!!!
Hi, i need the video's link "keep music playing when we leave our app" PLZ
Thanks
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 ?
How to do it using services??
It freezes when I click "Play"
Such a beautiful voice
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
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
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?
I want to create two raw directories is it possible?
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!
the first relaxing coding lessons in the world
If anyone have error in raw then take directory and named it raw
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!
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
Thank you
very much.
Super Bro nice video
And you can add the video coding Bro????
hello, why do you change constraint to relative layout?
Nothing happens when i click 'play' button, but 'stop' toast works fine
You are the best teacher I have ever seen.
@Coding in Flow Great tutorial! How can I use the speakers on the back of the smartphone?
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.
When i press the play button i got no sound! Please Help Me!
The channel is my main support for my android course in school
Dam i love your WORK BRO
You Great at this THINGS
LOVE YOU
hello
bro my mp3 file has saved as text file can u help me to change the file pls !!!!
Is there any problem if we use Stop method directly?
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)
mega interessant, danke und thank you ;o)
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
could you please give me the link for the next lesson (the services)
This is useless. You should teach people to load MediaFiles and do this actions in a Service Class.
LOVE YOU BOY!
Thank you very much! Clear and simple, just what I needed
Hi, thanks for your videos, can you please make a video about How to Play a Sound File list Using exoplayer? thanks
Eror:method stop in class mainactivity
Required View
Found no arguments
Dll
Can you do a tutorial for requesting and releasing AudioFocus?
Thanks for the video. It was very helpful!
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?
you are the best. thank you man
Sir after raw name i write music name but this is not show and get error
Have you tried setting PlayBacKParams?
Awesome video 🙂
you are the best
When trying to play the sound, I get this E/MediaPlayer: Should have subtitle controller already set, Any help please
Ty man, this is awesome
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?
how to do this with 20 different audio files in the same layout? using id on the button?
Is there a way to set the mediaPlayer to replay the previous iteration?