Control device media volume using Seekbar in Sketchware App
The Seekbar can be set to control media volume of device, when any media is playing, with the use of simple codes in add source directly block in Sketchware.
It only works if any audio is playing, otherwise it doesn't change the device audio volume.
In LOGIC area, in onCreate event add following code in end using add source directly block:
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); seekbar1.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
Create a More block and put following code in it using an add source directly block.
}
AudioManager audioManager;
private void nothing() {
In Seekbar onProgressChanged event add following code using add source directly block:
textview1.setText("Music Volume : " + _progressValue);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, _progressValue, 0);
That's all. Save and run the project. You should be able to change the volume of any music playing in device using the Seekbar.
It only works if any audio is playing, otherwise it doesn't change the device audio volume.
Some codes related to AudioManager.
Define AudioManager:
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Get Max Volume:
int max_volume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
Get Current Volume:
int current_volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
Set Volume to 70%:
int volume70 = (int) max_volume * 7 / 10;
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume70, 0);
Mute audio:
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, 0);
Unmute audio:
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_UNMUTE, 0);
Join this group for helping in developing have fun with this all groups making for only who like Android development using skitchware
ReplyDeleteTelegram group ->
https://t.me/joinchat/Fs_zjg8BLBEBf--zXas5SQ
WhatsApp group ->
https://chat.whatsapp.com/GthHkGFRfCW7oq4n13xlc3
Hi how I create a app that mutes the device volume on syart
DeleteStart*
DeleteAudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
DeleteaudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
Please add this groups link in your you tube channel because this will help u and me and all people so please
ReplyDeleteThanks you
...
Share link with ur friends and family
Send me your number please
Hi! How to make a program that changes or adjust the screen brightness of a device?
ReplyDeleteEu quero um linke pra fazer um mod para o maskgum
DeleteSbhdvyivei
DeleteaudioManager = (AudioManager) getSystemService (Context.AUDIO_SERVICE); ...
ReplyDeleteshould be...
AudioManager audioManager = (AudioManager) getSystemService (Context.AUDIO_SERVICE); ...
how to increase number using volume button in sketchware
ReplyDeleteEffectively, audio visual design consultants help clients, primarily in companies and organizations of all sizes, develop, install, and implement AV system plans. Know more from Fired Up Technologies
ReplyDeleteExcellent information, I am heartily very thankful to you for providing this kind of knowledge. This information will always help to everyone for gaining knowledge. Always keep sharing. Thanks for share free music app.
ReplyDelete