Hello Koders,
Today, I wanted to show how to make a switching button for turning a music ON or OFF. I had to use this in my own app now nearly finished, so I thought to make a Tutorial here.
This (first) tutorial is very simple and not the best at all , but it’s an interesting thing and nobody came up with the idea.
So, let’s start:
Designer:
We will use three components:
- A button
- A player (in my case, ExoPlayer)
- TinyDB
Now I have three assets that are not really neccessary for the logic, but for the result:
- A music
- A “unmute” image
- A “mute” image
That’s all in the Designer, let’s get into the kode!
We will have two block sections to get this working:
So, that’s it, guys!
If you have any questions or I did anything wrong to this guide or want to improve it, feel free to comment here. I am open to suggestions
All your friend, @Yoshi
PS : If anyone wants the .AIA file, here is it:
MusicSwitchGuide (1).aia (1.6 MB)
EDIT 1: Updated kode of TinyDB in Button on suggestion from @Kanishka_Developer. Thx!