1
00:00:01,710 --> 00:00:06,240
OK, in the last video, we worked on the pause function for a slider and this video, we want to look

2
00:00:06,240 --> 00:00:07,370
at the stop function.

3
00:00:07,380 --> 00:00:08,970
So let's head down to our stop function.

4
00:00:09,180 --> 00:00:14,610
And we want to just do the same thing we did with our paused function, with our stop function, which

5
00:00:14,610 --> 00:00:20,430
is create a variable that keeps track of whether or not the song has been stopped outside of the stop

6
00:00:20,430 --> 00:00:20,940
function.

7
00:00:21,240 --> 00:00:24,930
So we can comment create stopped variable.

8
00:00:27,280 --> 00:00:29,710
And let's go global stopped.

9
00:00:31,020 --> 00:00:37,320
And I want to make that lower case and let's get stopped to false by default, so when our program runs

10
00:00:37,740 --> 00:00:41,910
stopped is false because no songs have been played yet when the program first run.

11
00:00:41,920 --> 00:00:44,460
So therefore they haven't been stopped yet either.

12
00:00:44,640 --> 00:00:50,430
So then inside of here, at the bottom of our stop function, when we're stopping a song, we're stopping

13
00:00:50,430 --> 00:00:50,550
it.

14
00:00:50,560 --> 00:00:51,920
So we need to change.

15
00:00:52,260 --> 00:00:57,060
So set stop variable to true.

16
00:00:57,730 --> 00:01:00,180
So we again call global stopped.

17
00:01:01,020 --> 00:01:07,740
This will be accessed outside as well as inside this function and we could just set stopped to equal.

18
00:01:07,740 --> 00:01:08,270
True.

19
00:01:08,910 --> 00:01:14,910
OK, so now when we call it the stop button, this stopped variable will be true.

20
00:01:15,240 --> 00:01:18,720
So we can now come up to our play time function.

21
00:01:20,500 --> 00:01:28,090
And at the very top of this guy, let's check to see if song is stopped.

22
00:01:29,920 --> 00:01:33,280
So we can go if stopped return.

23
00:01:34,980 --> 00:01:35,700
So we're saying.

24
00:01:36,680 --> 00:01:40,770
If the stopped variable is true, that means the song has been stopped.

25
00:01:40,940 --> 00:01:45,680
If that's the case, then return what is returned to return stops everything.

26
00:01:45,680 --> 00:01:48,160
It stops everything in this function completely.

27
00:01:48,170 --> 00:01:50,630
So none of this stuff will happen.

28
00:01:51,230 --> 00:01:51,580
Right.

29
00:01:51,680 --> 00:01:54,770
And that makes sense because we don't want any of this stuff to happen.

30
00:01:54,770 --> 00:01:58,850
If a song's not playing right, if a song's not playing, we don't need to know the current time it's

31
00:01:58,850 --> 00:01:59,540
been stopped.

32
00:01:59,540 --> 00:02:00,290
It's zero.

33
00:02:00,500 --> 00:02:02,720
We don't need to know what the song is.

34
00:02:02,720 --> 00:02:03,650
It's been stopped.

35
00:02:03,800 --> 00:02:05,900
We don't need to know what the song length is.

36
00:02:06,290 --> 00:02:07,190
It's been stopped.

37
00:02:07,340 --> 00:02:08,930
We don't need to move the slider.

38
00:02:09,290 --> 00:02:10,760
There's no song playing to move.

39
00:02:10,760 --> 00:02:11,000
Right.

40
00:02:11,000 --> 00:02:13,370
So we don't need to update the status bar.

41
00:02:13,370 --> 00:02:20,390
It's a zero, but the song has stopped and we don't need this function to play again every second because

42
00:02:20,420 --> 00:02:21,320
there is no song.

43
00:02:21,320 --> 00:02:23,350
So it shouldn't be going every second.

44
00:02:23,360 --> 00:02:27,530
So this return thing up here, we'll just stop everything, go and say this and run it.

45
00:02:27,530 --> 00:02:29,120
See what we've got here.

46
00:02:31,180 --> 00:02:33,580
So let's add some songs you.

47
00:02:34,790 --> 00:02:36,020
Let's play one.

48
00:02:37,790 --> 00:02:44,590
Turn the volume down and we're moving right along, and if we stop, boom, it pops it back to the beginning

49
00:02:44,600 --> 00:02:47,340
are our status bar disappears.

50
00:02:47,390 --> 00:02:49,640
This thing is still here, but this is just a fake thing anyway.

51
00:02:49,640 --> 00:02:51,940
We're using for demonstration purposes.

52
00:02:51,950 --> 00:02:55,130
We're going to get rid of that eventually anyway, and we're good to go.

53
00:02:55,130 --> 00:02:57,200
So if we play a different song.

54
00:03:00,230 --> 00:03:07,520
All of this stuff doesn't start back up again, so we sort of have stopped, we need to now tell the

55
00:03:07,520 --> 00:03:11,570
world that the song that stopped is no longer true.

56
00:03:12,410 --> 00:03:13,310
It's playing again.

57
00:03:13,310 --> 00:03:13,540
Right.

58
00:03:13,550 --> 00:03:15,290
So we need to do that in our play function.

59
00:03:15,290 --> 00:03:18,680
So to do our play function and.

60
00:03:20,740 --> 00:03:26,260
Here it is, and just right at the top here, we can set global stopped.

61
00:03:28,090 --> 00:03:38,590
And let's make a comment set stopped to false, since a song is now playing right when we could play,

62
00:03:38,590 --> 00:03:39,760
it means we're playing.

63
00:03:39,760 --> 00:03:43,540
It means that definition be there for the song is not stopped.

64
00:03:43,540 --> 00:03:44,170
It's playing.

65
00:03:44,170 --> 00:03:45,010
So we lost.

66
00:03:45,010 --> 00:03:47,440
That stopped to false.

67
00:03:47,680 --> 00:03:47,980
All right.

68
00:03:47,980 --> 00:03:51,760
So let's go ahead and save this and run it.

69
00:03:51,790 --> 00:03:53,200
Make sure that worked.

70
00:03:57,230 --> 00:03:59,780
As some songs play one.

71
00:04:01,760 --> 00:04:09,860
It's moving along, we click, stop, goes back to nothing, pick another one, start to play it, everything

72
00:04:09,860 --> 00:04:13,260
gets reset and starts up again and we're good to go.

73
00:04:13,280 --> 00:04:13,910
Five seconds.

74
00:04:13,910 --> 00:04:14,480
Five seconds.

75
00:04:14,540 --> 00:04:16,480
We posit that stops.

76
00:04:16,490 --> 00:04:17,450
This is a little bit off.

77
00:04:17,450 --> 00:04:19,670
But again, we don't care about that so much right now.

78
00:04:19,850 --> 00:04:22,040
And we'll probably deal with that later if we have to.

79
00:04:22,280 --> 00:04:27,290
And OK, so our slider is now working seemingly the way we want.

80
00:04:27,290 --> 00:04:30,440
I'm sure there's going to be a little few more little things we're going to like this we're going to

81
00:04:30,440 --> 00:04:31,070
need to tweak.

82
00:04:31,370 --> 00:04:33,620
But for the most part, that's good.

83
00:04:34,150 --> 00:04:38,000
And let's see if we go to the next song.

84
00:04:39,340 --> 00:04:45,610
It doesn't reset, so and if we go back, it also, again, doesn't reset, so I think we'll look at

85
00:04:45,610 --> 00:04:46,930
that in the next video.
