Hey there at the moment we can play audio in our application and stop it.
Let's now add the functionality of a reduction increasing and decreasing of the sound.
This can be done in many ways but let's implement this with a new widget cigar bar go to activate the
main tab and type Sig bar
this widget.
Let's drag it and set it onto the bottom
let's call it for example volume Sig bar
and serrated
to the screen with
and let's add constraints
and let's run the application and see how it will look on the emulator screen
and we can adjust the sig bar to move the slider or wait install it anywhere.
Well now we need to bind this sig bar to the sound let's do this first by creating an object or rather
variable or the sig bar class call it Walden Sig bar and in their own create method
combined the sig bar variable with the allowed fine do you by D R I.D. Wolfram Sig bar
next to control and the position of the runner of the cigar.
We need to set on Sig bar change.
Listen up.
This is done as follows.
Once a bar that's set on Sig bar change.
Listen.
And here.
New on Sig bar.
Change listener
it is similar to how we created the Barton set on click listener here.
We set on say Sig bar change listener only here we have only one on click method and here we have three
methods for control.
We are currently interested in the first method on progress changed.
Progress is the deposition of the slider on the sig bar that is this is our progress it changes along
with the position of the slide and when the position changes we can't somehow react to it.
And these all start tracking touching on Star Trek and touch methods in these two methods so we can
to track when the user grabs this key the slider and the way it releases on stop tracking batch and
to execute some code and these methods but we will use their own Pyrex progress changed method for now.
Let's start by trying to write tall or cap progress as you can see here.
The parameters in their own progress change method are the first Sig bar then progress which is expressed
using an integer variable of type int and boolean from user there which indicates whether the impact
of SIG bar on the user is coming let's in this method right.
All a look look not these and here we write progress changed
and then we specify the value of our int variable progress.
But since a string is required here we concatenate progress with all our string and now let's see how
we'll pub how progress will display up in our look at
let's open.
Now look at
and you see I can drag the slider and progress values change as I move it.
They can change from 1 to 100 and now we need to call it Sig bar with our salt.
This is done using the order manager.
Let's create a variable of class out the manager
and in the method on create.
We initialize it we call the system source gate system service.
And here we specify what we need order service.
We service we need androids to do emphasize this to us and write that the order manager class is required
and the object class this fall.
This happens because get system service can return different services and it returns.
These result in the form of the object class but since we know that this object is our audio manager
now we can do the so-called cost.
We will right here in the parentheses order manager and now we need to set the maximum sound for our
sick bar.
Since the maximum sat with us may not be equals 100 but something else.
Let's create the variable in let's call it max volume and assign it the value obtained from the order
manager gets 3 max volume.
And here we indicate that we need the maximum sound value for their music stream.
Stream music next.
Or we assign the maximum value for our Sig bar and set this value to the maximum value of the value.
Further in the method on progress changed which controls the change of the progress of all a sick bar.
We do the following.
We set our sound in this way.
Order manager sets removal again specify that time stream music then specify the progress parameter
that displays progress in our sick bar.
And here we need to set the flag.
Set it to 0.
You may not think about it.
Just set it to 0.
Let's now run the application
or it's close so I'll cut
to it at all and 5.
We can adjust the sum.