OK, now we want to start to talk about the forward and the back buttons, and these are also a little
bit tricky.
So just sort of think about it.
How would you make a forward button and a back button go if you know that the current song is no win
and you said play the next song.
Well, what is the next song North?
How do we know that?
We don't know which song is in the list?
We have no idea.
But what we do know is the number.
So each of these items are numbered like a python list.
So this first one is zero.
This one's one, two, three, four or five.
So we could say, hey, play the current song plus one to go forward or we can say, hey, play the
current song, minus one to go back.
And we don't really need to know what the names of the songs are.
We could just use those numbers.
So in a nutshell, that's what we're going to do.
So let's start to do that.
So head over to our code and I'm going to call these next song and previous song functions.
So let's come down to our buttons.
So we've got the back button and the forward button.
Let's do the forward button first.
So let's go command.
Equals next song.
OK, so let's not create that guy so down here below.
Let's go to.
Create function to play the next song, and we want to define next song, we're not passing anything
into it, so.
Let's get current song number so that one and I'm going to call this next so or next song.
Well, we don't want to call the next song because we call this function next song.
Let's call it next one.
Right.
All right.
So that will be remember, our playlist is called The Playlist Box, so we can reference it by calling
playlist box dot.
We can get the color selection.
So this will tell us what the current selection is that we've highlighted that the green bar is on,
so remember are a little label guy here.
We're going to use this a lot.
Let's go ahead and look and see what that is actually returning.
So let's go my label dot config and set the text equal to next underscore one.
So we just want to see what this is.
So let's go and save this and run it.
So let's add a bunch of songs.
So let's click on this one, the very first one now, if we click the next button right here, you see
it return zero.
Remember, this is the zero one.
This one is one.
So we can click here and boom.
Now one, this one is going to be the last one.
So zero, one, two, three, four, five.
This should return five, boom five.
So we've got a number so we can say, hey, now play this number plus one.
You know, we're currently on this zero.
We want to play the next one, which will be zero plus one, which is one, which is this one makes
sense.
So, OK.
Let's get rid of this label.
We don't really need it, so we want to set the next one as the next one.
So let's go next.
Underscore one equals next.
Underscore one.
And let's go zero.
Plus one now.
This is a little confusing because this number zero is not zero, right?
I'm calling this because.
This doesn't really return a no, it looked like it did when we just looked at it, it was returning
zero or one or five or whatever, but that wasn't a number.
That was a list with a number in it.
And we can actually see that by printing this out.
So let's go print next, underscore one.
This will print it to the actual terminal.
So let's just save this really quickly and run this one more time.
And let's add some songs.
This one is the fifth one, and if we click this, nothing happens, but when we close this, we can
see down here in the terminal it's returning a python tuple or a python list and tuples or the same
thing, basically, almost.
But you can see it's ordered it's got five.
That's the thing.
The song number is five, but it's in a tuple.
So to access five, we we have to call the zeroth item from the tuple.
Right.
The zero with item here is five.
So does that make sense.
So since this is returning as it sort of a tuple as a list, we have to call, you know, to get five,
we have to call the zeroth item to do that.
We call.
Let's get right to this.
We call the zeroth item of the list, which will return whatever this current selection is, then we
want to just add one to it, right?
So if we're on song number three, next one will end up being four.
Right.
And let's come at this for good measure.
Let's go add one to the current song number.
The this thing.
OK, so this video is getting a little bit long, I think we'll stop right here and pick this up in
the next video.