OK, in this video, I want to show you how to deal with the pause button and a stop button when it
comes to our slider moving.
So let's look down at our pause function real quick.
And you'll remember, we have this global variable called pause, so when the so when the program is
paused, right.
The paused variable is set to true.
So we know if the paused variable is true, the thing has been paused so we can stop our slider from
moving if our pause variable is true.
So if our pause variable is true.
So that's a great thing for an if statement.
So let's say back up to our play time function and let's head over here to where we're moving our slider
along and let's create a new statement.
So if paused.
We want to pass, we want to do anything else, let's do all of this stuff right.
So remember when we used an F statement, if we just call the variable that's saying in effect is shorthand
for if paused equals true, we could set this to equals true like that now would be the same thing is
just typing if paused like that.
So this is saying if this is true then pass this guy.
It just means stop.
Right.
Just, just don't do anything right.
Just drop down and continue on right here with our status bar stuff else.
If it's not paused, if it's false, that means it's not paused.
And if it's not paused, then continue on.
So, all right, let's take this and run it, see if that did the trick for that one.
So add songs you.
And let's play one.
Volume down.
So we're moving along now if we pause it.
Now, this and this aren't quite synching up, that may be a problem later.
Keep a note of that.
And we unpause this.
Now these two numbers are not synched again.
So that's a little bit of a problem.
Right?
So we could fix that right away by resetting this guy.
So let's come back over here and look at this.
So instead of here, we could say song underscore slider, config value equals.
Remember up here, we've got our current time, but I don't really want to do it like this, we'll do
it like this for now, but now.
This is not a great way to do this.
We can save this and give it a shot, just see.
I want to say, man, 30 seconds.
Turn the volume down a bit.
Pause it.
It goes on to seven.
It scales back to six point five.
Right, because that's what the actual time is.
Six to seven, eight, nine, ten, we it again, 12 and 12, twelve point two.
OK, so that seems to work.
But we're going to have problems with this in the future, I can see it was at 16, ratchet it back
to fifteen point nine seven.
Right.
It's just it's just taking the integer value, basically, so.
Yeah, that kind of works, but like I said, there's two problems with this in the future, and the
reason why I might as well tell you now is eventually we're going to be able to move this thing around.
You see, it snaps it back now and move the song around accordingly.
But when we do that, this time lapse thing gets all messed up, because when we're fast forwarding,
we're not fast forwarding.
What we're doing is playing the song a second time from a different starting position.
So the elapsed time gets reset to zero every time we move this thing around.
So in that case, this pause thing doesn't quite work out.
So we may have to deal with that.
But for now, this this seems to work.
And in fact, I'm going to close this and I'm just going to take this off here.
We actually don't want that.
We'll just move it back to pass and we'll deal with the inconsistencies later.
But OK, that's how we can do pause.
I was going to do I was going to do stop in this video as well.
But this video is getting a little bit long, so I think we'll do stop in the next video.