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.

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key