1
00:00:01,740 --> 00:00:06,010
OK, in this video, I want to show you how to deal with the pause button and a stop button when it

2
00:00:06,010 --> 00:00:07,300
comes to our slider moving.

3
00:00:07,300 --> 00:00:09,910
So let's look down at our pause function real quick.

4
00:00:11,840 --> 00:00:19,490
And you'll remember, we have this global variable called pause, so when the so when the program is

5
00:00:19,490 --> 00:00:20,990
paused, right.

6
00:00:21,230 --> 00:00:23,650
The paused variable is set to true.

7
00:00:23,990 --> 00:00:31,820
So we know if the paused variable is true, the thing has been paused so we can stop our slider from

8
00:00:31,820 --> 00:00:33,760
moving if our pause variable is true.

9
00:00:33,980 --> 00:00:36,330
So if our pause variable is true.

10
00:00:36,470 --> 00:00:38,500
So that's a great thing for an if statement.

11
00:00:38,510 --> 00:00:44,960
So let's say back up to our play time function and let's head over here to where we're moving our slider

12
00:00:44,960 --> 00:00:46,700
along and let's create a new statement.

13
00:00:46,730 --> 00:00:48,530
So if paused.

14
00:00:50,860 --> 00:00:56,910
We want to pass, we want to do anything else, let's do all of this stuff right.

15
00:00:57,430 --> 00:01:03,100
So remember when we used an F statement, if we just call the variable that's saying in effect is shorthand

16
00:01:03,100 --> 00:01:09,880
for if paused equals true, we could set this to equals true like that now would be the same thing is

17
00:01:09,880 --> 00:01:12,220
just typing if paused like that.

18
00:01:12,470 --> 00:01:16,930
So this is saying if this is true then pass this guy.

19
00:01:17,440 --> 00:01:19,030
It just means stop.

20
00:01:19,040 --> 00:01:19,260
Right.

21
00:01:19,300 --> 00:01:21,330
Just, just don't do anything right.

22
00:01:21,700 --> 00:01:26,530
Just drop down and continue on right here with our status bar stuff else.

23
00:01:26,530 --> 00:01:30,730
If it's not paused, if it's false, that means it's not paused.

24
00:01:30,880 --> 00:01:33,190
And if it's not paused, then continue on.

25
00:01:33,220 --> 00:01:37,720
So, all right, let's take this and run it, see if that did the trick for that one.

26
00:01:38,750 --> 00:01:40,940
So add songs you.

27
00:01:42,490 --> 00:01:43,540
And let's play one.

28
00:01:45,870 --> 00:01:46,720
Volume down.

29
00:01:46,980 --> 00:01:48,930
So we're moving along now if we pause it.

30
00:01:55,210 --> 00:02:00,280
Now, this and this aren't quite synching up, that may be a problem later.

31
00:02:00,970 --> 00:02:01,870
Keep a note of that.

32
00:02:01,960 --> 00:02:03,190
And we unpause this.

33
00:02:06,070 --> 00:02:09,090
Now these two numbers are not synched again.

34
00:02:09,430 --> 00:02:10,960
So that's a little bit of a problem.

35
00:02:11,350 --> 00:02:11,650
Right?

36
00:02:11,650 --> 00:02:15,960
So we could fix that right away by resetting this guy.

37
00:02:15,970 --> 00:02:17,710
So let's come back over here and look at this.

38
00:02:17,710 --> 00:02:26,110
So instead of here, we could say song underscore slider, config value equals.

39
00:02:27,670 --> 00:02:32,530
Remember up here, we've got our current time, but I don't really want to do it like this, we'll do

40
00:02:32,530 --> 00:02:35,850
it like this for now, but now.

41
00:02:37,150 --> 00:02:39,250
This is not a great way to do this.

42
00:02:39,280 --> 00:02:41,680
We can save this and give it a shot, just see.

43
00:02:49,570 --> 00:02:50,880
I want to say, man, 30 seconds.

44
00:02:51,220 --> 00:02:52,420
Turn the volume down a bit.

45
00:02:53,940 --> 00:02:54,830
Pause it.

46
00:02:54,980 --> 00:02:56,770
It goes on to seven.

47
00:02:57,250 --> 00:02:59,740
It scales back to six point five.

48
00:03:00,590 --> 00:03:02,660
Right, because that's what the actual time is.

49
00:03:05,470 --> 00:03:13,060
Six to seven, eight, nine, ten, we it again, 12 and 12, twelve point two.

50
00:03:14,020 --> 00:03:15,640
OK, so that seems to work.

51
00:03:17,720 --> 00:03:24,740
But we're going to have problems with this in the future, I can see it was at 16, ratchet it back

52
00:03:24,740 --> 00:03:26,540
to fifteen point nine seven.

53
00:03:26,540 --> 00:03:26,790
Right.

54
00:03:26,810 --> 00:03:29,870
It's just it's just taking the integer value, basically, so.

55
00:03:31,110 --> 00:03:35,550
Yeah, that kind of works, but like I said, there's two problems with this in the future, and the

56
00:03:35,550 --> 00:03:40,110
reason why I might as well tell you now is eventually we're going to be able to move this thing around.

57
00:03:40,860 --> 00:03:45,350
You see, it snaps it back now and move the song around accordingly.

58
00:03:45,360 --> 00:03:51,210
But when we do that, this time lapse thing gets all messed up, because when we're fast forwarding,

59
00:03:51,210 --> 00:03:52,380
we're not fast forwarding.

60
00:03:52,380 --> 00:03:57,690
What we're doing is playing the song a second time from a different starting position.

61
00:03:57,870 --> 00:04:01,990
So the elapsed time gets reset to zero every time we move this thing around.

62
00:04:02,010 --> 00:04:05,790
So in that case, this pause thing doesn't quite work out.

63
00:04:06,000 --> 00:04:07,530
So we may have to deal with that.

64
00:04:08,010 --> 00:04:09,800
But for now, this this seems to work.

65
00:04:10,590 --> 00:04:15,600
And in fact, I'm going to close this and I'm just going to take this off here.

66
00:04:16,710 --> 00:04:17,700
We actually don't want that.

67
00:04:17,700 --> 00:04:22,110
We'll just move it back to pass and we'll deal with the inconsistencies later.

68
00:04:22,380 --> 00:04:24,690
But OK, that's how we can do pause.

69
00:04:25,050 --> 00:04:28,170
I was going to do I was going to do stop in this video as well.

70
00:04:28,170 --> 00:04:31,890
But this video is getting a little bit long, so I think we'll do stop in the next video.
