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.

In your Sketchware project, in VIEW area add a TextView (textview1) and a SeekBar (seekbar1).

Set the progress of Seekbar to 12.

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));
}
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.

Comments

  1. Join this group for helping in developing have fun with this all groups making for only who like Android development using skitchware

    Telegram group ->
    https://t.me/joinchat/Fs_zjg8BLBEBf--zXas5SQ

    WhatsApp group ->
    https://chat.whatsapp.com/GthHkGFRfCW7oq4n13xlc3

    ReplyDelete
    Replies
    1. Hi how I create a app that mutes the device volume on syart

      Delete
    2. AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
      audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);

      Delete
  2. Please add this groups link in your you tube channel because this will help u and me and all people so please

    Thanks you



    ...
    Share link with ur friends and family



    Send me your number please

    ReplyDelete
  3. Hi! How to make a program that changes or adjust the screen brightness of a device?

    ReplyDelete
  4. audioManager = (AudioManager) getSystemService (Context.AUDIO_SERVICE); ...

    should be...

    AudioManager audioManager = (AudioManager) getSystemService (Context.AUDIO_SERVICE); ...

    ReplyDelete

Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Create Music Player app in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity