1
00:00:01,600 --> 00:00:05,510
OK, so you can see our guy here is continuing to just keep going.

2
00:00:05,530 --> 00:00:10,210
So now we're at three minutes and 23 seconds, even though the song is only two minutes and 30 seconds

3
00:00:10,210 --> 00:00:11,470
long, just keeps going.

4
00:00:11,680 --> 00:00:12,030
Right.

5
00:00:12,050 --> 00:00:13,990
So we need to fix that.

6
00:00:14,000 --> 00:00:19,240
So one thing we could do is we can run an if statement to say if the current slider position equals

7
00:00:19,240 --> 00:00:22,390
the song length, that means the song is over.

8
00:00:22,900 --> 00:00:24,340
Stop, stop counting.

9
00:00:24,340 --> 00:00:25,060
Stop everything.

10
00:00:25,060 --> 00:00:26,620
So that's basically what we're going to do.

11
00:00:26,710 --> 00:00:27,400
Very simple.

12
00:00:27,400 --> 00:00:32,890
So let's head back over to our code and let's head over to our play time function.

13
00:00:32,920 --> 00:00:34,840
So what is the end of the song?

14
00:00:35,020 --> 00:00:37,360
Well, that is our song length.

15
00:00:37,750 --> 00:00:41,320
And remember, we converted this two time format.

16
00:00:41,530 --> 00:00:43,960
That's what this converted song length is up here.

17
00:00:44,260 --> 00:00:45,510
But we don't really want that.

18
00:00:45,520 --> 00:00:47,850
We're just going to compare the actual length, right.

19
00:00:47,890 --> 00:00:49,530
The song length itself.

20
00:00:49,930 --> 00:00:52,870
So whatever many seconds the song is.

21
00:00:52,870 --> 00:01:00,160
So we can use this song length variable and we know any time we want what the song slider position is

22
00:01:00,160 --> 00:01:01,780
by calling song slider aget.

23
00:01:02,050 --> 00:01:04,590
So we know the two things we can now compare.

24
00:01:04,840 --> 00:01:10,300
So up here, let's start another if statement and we're going to link all these together.

25
00:01:10,660 --> 00:01:11,490
So let's go.

26
00:01:11,500 --> 00:01:16,570
If the integer value of song underscore slider get.

27
00:01:18,070 --> 00:01:24,400
Equals the integer value of whatever the song length is, then do something.

28
00:01:27,520 --> 00:01:37,460
So up here, let's check to see if song is over, so why integer value?

29
00:01:37,720 --> 00:01:44,200
Well, because we've seen inconsistencies from time to time between the slider and the song values,

30
00:01:44,200 --> 00:01:44,500
right?

31
00:01:44,500 --> 00:01:47,070
So they may be off just milliseconds.

32
00:01:47,080 --> 00:01:52,810
It might be the song Slider might be at one fifty point to four and the end of the song, maybe one

33
00:01:52,810 --> 00:01:55,530
fifty point to three.

34
00:01:55,690 --> 00:01:57,640
You know, they just might not sync up quite.

35
00:01:57,700 --> 00:02:01,330
If we just convert them to integers, then they're both going to be one fifty.

36
00:02:01,510 --> 00:02:02,820
And that's easier to compare.

37
00:02:02,830 --> 00:02:04,630
So let's just do that.

38
00:02:04,630 --> 00:02:07,810
It really doesn't matter all that much, but that's probably better.

39
00:02:07,990 --> 00:02:12,340
So what do we want to happen when the slider gets to the end?

40
00:02:12,610 --> 00:02:15,830
Well, we could just run the stop function, right?

41
00:02:15,850 --> 00:02:23,440
So if we come down here and look at our stop function again, the stop function stops the song.

42
00:02:24,130 --> 00:02:24,550
Right?

43
00:02:24,850 --> 00:02:27,790
It clears the thing from the playlist.

44
00:02:27,790 --> 00:02:30,130
It resets the status bar.

45
00:02:30,460 --> 00:02:32,320
It sets the song Slider.

46
00:02:33,230 --> 00:02:40,490
Back to zero, so it no longer goes anymore, and it sets stopped to true, at which point.

47
00:02:43,390 --> 00:02:47,020
Here in our play time if stopped equals true.

48
00:02:48,170 --> 00:02:56,870
It turns off this play time function, so this guy down here will stop adding one because this whole

49
00:02:56,870 --> 00:02:58,110
thing will have stopped, right?

50
00:02:58,430 --> 00:03:00,350
So, OK, that probably will work.

51
00:03:01,110 --> 00:03:02,160
We could just do that.

52
00:03:02,180 --> 00:03:07,130
So but now we need to link these things together.

53
00:03:07,130 --> 00:03:09,040
So we want all of this to be one statement.

54
00:03:09,050 --> 00:03:13,130
So I'm going to change this to an ELF statement.

55
00:03:13,490 --> 00:03:17,060
So if this equals true elf.

56
00:03:18,260 --> 00:03:24,860
Let's say check to see if paused, if so.

57
00:03:28,900 --> 00:03:29,710
Or pass.

58
00:03:31,010 --> 00:03:38,510
Maybe, if so, pass, right, so OK, so our logic goes, if the song Slider is at the end of the thing

59
00:03:38,720 --> 00:03:42,560
and it equals the song length, that means the whole thing's done playing.

60
00:03:42,560 --> 00:03:43,880
So therefore stop.

61
00:03:44,450 --> 00:03:47,690
Or else if it's paused, stop.

62
00:03:48,770 --> 00:03:55,330
Else otherwise do all the stuff, so if this is true, none of this.

63
00:03:57,570 --> 00:04:04,830
Will work, will none of that will fire, will run, right, specifically, especially this won't run.

64
00:04:04,840 --> 00:04:06,970
So if this is true, this won't run.

65
00:04:07,110 --> 00:04:09,400
If this is true, this won't run.

66
00:04:09,840 --> 00:04:15,300
So if either of these things if both of these things are false, then this runs, which is what we want.

67
00:04:15,310 --> 00:04:18,930
So, OK, let's go ahead and save this and run it and give this a C.

68
00:04:21,760 --> 00:04:23,020
So let's have some songs.

69
00:04:28,200 --> 00:04:31,860
And let's play one volume down.

70
00:04:33,950 --> 00:04:36,960
Move it forward with back.

71
00:04:39,530 --> 00:04:45,860
Towards the end, one three four one three five one three six one thirty seven thirty eight thirty nine

72
00:04:46,340 --> 00:04:47,720
one forty boom.

73
00:04:49,630 --> 00:04:51,250
Song stops, right?

74
00:04:51,970 --> 00:04:58,510
And that works now if we come to the next song and hit play starts right up again and everything is

75
00:04:58,510 --> 00:04:59,380
working correctly.

76
00:04:59,950 --> 00:05:03,190
OK, so I think that's pretty much it for the slider.

77
00:05:03,190 --> 00:05:03,520
Right.

78
00:05:04,170 --> 00:05:04,700
Um.

79
00:05:05,850 --> 00:05:12,610
I think so, and I think that might be it for the course now, we might want to change this length here.

80
00:05:12,970 --> 00:05:17,240
Remember, we changed it so that our little output thing could go on to the screen.

81
00:05:17,250 --> 00:05:22,320
So if we change this back to four hundred, save this guy and run it again.

82
00:05:23,930 --> 00:05:26,090
So that's a little bit better size wise.

83
00:05:27,800 --> 00:05:29,200
And which songs to.

84
00:05:34,470 --> 00:05:39,230
So, yeah, I think that's it in the next video will say a few more things and wrap this all up.
