1
00:00:01,580 --> 00:00:05,750
OK, now we want to start to talk about the forward and the back buttons, and these are also a little

2
00:00:05,750 --> 00:00:06,260
bit tricky.

3
00:00:06,260 --> 00:00:08,120
So just sort of think about it.

4
00:00:08,120 --> 00:00:13,940
How would you make a forward button and a back button go if you know that the current song is no win

5
00:00:14,180 --> 00:00:15,540
and you said play the next song.

6
00:00:15,560 --> 00:00:18,350
Well, what is the next song North?

7
00:00:18,800 --> 00:00:19,640
How do we know that?

8
00:00:19,640 --> 00:00:21,650
We don't know which song is in the list?

9
00:00:21,680 --> 00:00:22,430
We have no idea.

10
00:00:22,940 --> 00:00:24,740
But what we do know is the number.

11
00:00:24,950 --> 00:00:29,160
So each of these items are numbered like a python list.

12
00:00:29,390 --> 00:00:30,880
So this first one is zero.

13
00:00:30,920 --> 00:00:33,560
This one's one, two, three, four or five.

14
00:00:33,780 --> 00:00:40,040
So we could say, hey, play the current song plus one to go forward or we can say, hey, play the

15
00:00:40,040 --> 00:00:42,650
current song, minus one to go back.

16
00:00:42,830 --> 00:00:46,250
And we don't really need to know what the names of the songs are.

17
00:00:46,250 --> 00:00:47,470
We could just use those numbers.

18
00:00:47,690 --> 00:00:49,730
So in a nutshell, that's what we're going to do.

19
00:00:49,740 --> 00:00:50,810
So let's start to do that.

20
00:00:50,810 --> 00:00:56,860
So head over to our code and I'm going to call these next song and previous song functions.

21
00:00:56,860 --> 00:00:58,370
So let's come down to our buttons.

22
00:00:58,640 --> 00:01:00,860
So we've got the back button and the forward button.

23
00:01:00,860 --> 00:01:02,600
Let's do the forward button first.

24
00:01:02,900 --> 00:01:05,150
So let's go command.

25
00:01:07,220 --> 00:01:10,390
Equals next song.

26
00:01:11,620 --> 00:01:16,450
OK, so let's not create that guy so down here below.

27
00:01:17,410 --> 00:01:18,730
Let's go to.

28
00:01:20,970 --> 00:01:31,770
Create function to play the next song, and we want to define next song, we're not passing anything

29
00:01:31,770 --> 00:01:33,060
into it, so.

30
00:01:34,540 --> 00:01:45,860
Let's get current song number so that one and I'm going to call this next so or next song.

31
00:01:45,880 --> 00:01:48,790
Well, we don't want to call the next song because we call this function next song.

32
00:01:48,970 --> 00:01:50,370
Let's call it next one.

33
00:01:50,980 --> 00:01:51,400
Right.

34
00:01:52,090 --> 00:01:52,450
All right.

35
00:01:52,450 --> 00:01:58,570
So that will be remember, our playlist is called The Playlist Box, so we can reference it by calling

36
00:01:58,570 --> 00:02:00,580
playlist box dot.

37
00:02:00,700 --> 00:02:02,950
We can get the color selection.

38
00:02:05,530 --> 00:02:12,130
So this will tell us what the current selection is that we've highlighted that the green bar is on,

39
00:02:12,140 --> 00:02:14,910
so remember are a little label guy here.

40
00:02:14,920 --> 00:02:15,970
We're going to use this a lot.

41
00:02:16,630 --> 00:02:19,720
Let's go ahead and look and see what that is actually returning.

42
00:02:19,730 --> 00:02:27,660
So let's go my label dot config and set the text equal to next underscore one.

43
00:02:28,180 --> 00:02:30,410
So we just want to see what this is.

44
00:02:30,460 --> 00:02:31,960
So let's go and save this and run it.

45
00:02:35,580 --> 00:02:37,470
So let's add a bunch of songs.

46
00:02:39,510 --> 00:02:46,800
So let's click on this one, the very first one now, if we click the next button right here, you see

47
00:02:46,800 --> 00:02:47,720
it return zero.

48
00:02:47,730 --> 00:02:49,280
Remember, this is the zero one.

49
00:02:49,410 --> 00:02:51,470
This one is one.

50
00:02:51,480 --> 00:02:53,010
So we can click here and boom.

51
00:02:53,010 --> 00:02:55,620
Now one, this one is going to be the last one.

52
00:02:55,620 --> 00:02:58,740
So zero, one, two, three, four, five.

53
00:02:58,950 --> 00:03:01,200
This should return five, boom five.

54
00:03:01,200 --> 00:03:06,510
So we've got a number so we can say, hey, now play this number plus one.

55
00:03:06,810 --> 00:03:09,390
You know, we're currently on this zero.

56
00:03:09,390 --> 00:03:16,050
We want to play the next one, which will be zero plus one, which is one, which is this one makes

57
00:03:16,050 --> 00:03:16,350
sense.

58
00:03:16,770 --> 00:03:17,400
So, OK.

59
00:03:18,600 --> 00:03:20,910
Let's get rid of this label.

60
00:03:20,940 --> 00:03:24,910
We don't really need it, so we want to set the next one as the next one.

61
00:03:24,930 --> 00:03:25,830
So let's go next.

62
00:03:25,830 --> 00:03:30,150
Underscore one equals next.

63
00:03:30,150 --> 00:03:31,440
Underscore one.

64
00:03:33,640 --> 00:03:34,780
And let's go zero.

65
00:03:35,870 --> 00:03:37,400
Plus one now.

66
00:03:38,370 --> 00:03:45,060
This is a little confusing because this number zero is not zero, right?

67
00:03:45,510 --> 00:03:47,250
I'm calling this because.

68
00:03:48,240 --> 00:03:54,000
This doesn't really return a no, it looked like it did when we just looked at it, it was returning

69
00:03:54,000 --> 00:03:57,420
zero or one or five or whatever, but that wasn't a number.

70
00:03:57,420 --> 00:03:59,940
That was a list with a number in it.

71
00:04:00,090 --> 00:04:03,360
And we can actually see that by printing this out.

72
00:04:03,370 --> 00:04:06,990
So let's go print next, underscore one.

73
00:04:07,020 --> 00:04:09,090
This will print it to the actual terminal.

74
00:04:09,310 --> 00:04:11,850
So let's just save this really quickly and run this one more time.

75
00:04:14,030 --> 00:04:15,770
And let's add some songs.

76
00:04:18,000 --> 00:04:22,860
This one is the fifth one, and if we click this, nothing happens, but when we close this, we can

77
00:04:22,860 --> 00:04:28,980
see down here in the terminal it's returning a python tuple or a python list and tuples or the same

78
00:04:28,980 --> 00:04:30,350
thing, basically, almost.

79
00:04:30,870 --> 00:04:34,400
But you can see it's ordered it's got five.

80
00:04:34,410 --> 00:04:35,340
That's the thing.

81
00:04:35,670 --> 00:04:38,730
The song number is five, but it's in a tuple.

82
00:04:38,730 --> 00:04:44,100
So to access five, we we have to call the zeroth item from the tuple.

83
00:04:44,610 --> 00:04:45,000
Right.

84
00:04:45,210 --> 00:04:47,400
The zero with item here is five.

85
00:04:48,000 --> 00:04:49,170
So does that make sense.

86
00:04:49,350 --> 00:04:55,080
So since this is returning as it sort of a tuple as a list, we have to call, you know, to get five,

87
00:04:55,080 --> 00:04:57,510
we have to call the zeroth item to do that.

88
00:04:57,510 --> 00:04:58,380
We call.

89
00:04:59,630 --> 00:05:00,560
Let's get right to this.

90
00:05:02,730 --> 00:05:10,290
We call the zeroth item of the list, which will return whatever this current selection is, then we

91
00:05:10,290 --> 00:05:12,090
want to just add one to it, right?

92
00:05:12,330 --> 00:05:17,910
So if we're on song number three, next one will end up being four.

93
00:05:18,360 --> 00:05:18,680
Right.

94
00:05:19,710 --> 00:05:21,780
And let's come at this for good measure.

95
00:05:22,090 --> 00:05:28,260
Let's go add one to the current song number.

96
00:05:30,050 --> 00:05:31,170
The this thing.

97
00:05:32,000 --> 00:05:35,780
OK, so this video is getting a little bit long, I think we'll stop right here and pick this up in

98
00:05:35,780 --> 00:05:36,410
the next video.
