1
00:00:01,610 --> 00:00:09,020
OK, in this video, we want to convert our our label thing here this current time into a time format.

2
00:00:09,020 --> 00:00:13,110
So you think of your watch 12 01 and 12 seconds, right?

3
00:00:13,370 --> 00:00:19,390
That's one to call in zero zero colon, five for five seconds.

4
00:00:19,400 --> 00:00:19,610
Right.

5
00:00:19,640 --> 00:00:20,770
So how do we do that?

6
00:00:20,780 --> 00:00:24,610
Well, Python comes with a module that works with time and we can import that up here.

7
00:00:24,620 --> 00:00:25,350
So let's do that now.

8
00:00:25,350 --> 00:00:27,260
So let's just import time now.

9
00:00:27,260 --> 00:00:35,650
We can come down here to our play time function and and let's change this current time into time format.

10
00:00:35,660 --> 00:00:36,830
So to do that.

11
00:00:38,470 --> 00:00:42,700
Let's call this converted, underscore our current.

12
00:00:44,100 --> 00:00:50,700
Underscore times, we're going to convert this to time format and to do that we call time dot star f

13
00:00:50,700 --> 00:00:51,240
time.

14
00:00:51,510 --> 00:00:55,710
So this is string F time basically, and now we want to convert this.

15
00:00:55,710 --> 00:00:57,150
What format do we want?

16
00:00:57,390 --> 00:01:02,790
Well, let's put minutes and seconds.

17
00:01:03,300 --> 00:01:03,690
Right.

18
00:01:03,720 --> 00:01:08,730
So then we can now swap this out for time.

19
00:01:08,730 --> 00:01:10,940
Dot GM time.

20
00:01:12,020 --> 00:01:16,280
And then what are we converting to this thing here?

21
00:01:16,700 --> 00:01:25,360
Well, we're converting our current time variable so we can copy this and paste this in there, right?

22
00:01:25,860 --> 00:01:26,960
OK, so convert.

23
00:01:27,320 --> 00:01:31,190
So now our time is stored in this converted current time variable.

24
00:01:31,370 --> 00:01:36,710
So let's copy this and let's add this to the label instead of our current time just to see what this

25
00:01:36,710 --> 00:01:37,170
looks like.

26
00:01:37,190 --> 00:01:39,820
So let's go ahead and save this.

27
00:01:39,830 --> 00:01:41,630
Now, we can also put H.

28
00:01:41,990 --> 00:01:44,960
So we can put the hours, the minutes and the seconds.

29
00:01:45,260 --> 00:01:47,920
But I don't think our songs are ever going to be an hour long.

30
00:01:47,960 --> 00:01:49,280
They're going to be minutes long.

31
00:01:49,280 --> 00:01:51,170
So we'll just leave it at minutes and seconds.

32
00:01:51,380 --> 00:01:54,970
OK, let's go ahead and save this and run this guy and see what this looks like.

33
00:01:54,980 --> 00:01:56,180
So add songs.

34
00:01:57,970 --> 00:01:59,410
I guess we just had one.

35
00:02:02,050 --> 00:02:04,180
Oh, get in there somewhere.

36
00:02:04,210 --> 00:02:05,620
Let's see, what did we forget to do?

37
00:02:07,300 --> 00:02:09,610
Invalid literal line twenty one.

38
00:02:10,330 --> 00:02:11,200
Oh yeah.

39
00:02:11,620 --> 00:02:14,320
We don't need to change this to an integer.

40
00:02:14,860 --> 00:02:18,190
We just want to convert at current time and our label.

41
00:02:18,190 --> 00:02:19,870
So, OK, let's go and save this and run it.

42
00:02:22,520 --> 00:02:26,000
And pull this over, add some songs or.

43
00:02:26,980 --> 00:02:27,760
One song.

44
00:02:29,060 --> 00:02:32,930
60 now is zero zero colon's zero three zero four.

45
00:02:33,080 --> 00:02:41,830
This is more of a time when you look at an MP three player or something, you expect to see time format.

46
00:02:41,840 --> 00:02:44,630
So, OK, so this is working out why we've got this here.

47
00:02:44,630 --> 00:02:49,790
Why don't we just put this down here where it says nothing and so this will be in our status bar.

48
00:02:50,030 --> 00:02:51,590
So let's do that real quick.

49
00:02:51,770 --> 00:02:52,940
So come down here.

50
00:02:52,940 --> 00:02:57,020
And our status bar was this guy.

51
00:02:58,800 --> 00:03:02,160
And let's take this text of nothing out of there.

52
00:03:02,340 --> 00:03:09,840
So when the app runs, there won't be anything down there, but we can then config our status bar up

53
00:03:09,840 --> 00:03:11,580
here in our play time function.

54
00:03:12,270 --> 00:03:14,790
So we'll see where we're at.

55
00:03:15,270 --> 00:03:22,500
We go play time function now instead of my labeled config, let's statis bar config and I'm just going

56
00:03:22,500 --> 00:03:25,650
to copy this whole thing and paste it there.

57
00:03:26,250 --> 00:03:28,830
And we don't need this label anymore so we can get rid of that.

58
00:03:29,310 --> 00:03:32,160
And let's see, let's add some comments here.

59
00:03:32,160 --> 00:03:39,510
So let's go grab current song time here.

60
00:03:39,510 --> 00:03:43,500
Let's go convert song time.

61
00:03:47,740 --> 00:03:49,360
Time format.

62
00:03:50,820 --> 00:03:57,990
And here, let's go and current time to status bar.

63
00:03:59,940 --> 00:04:04,890
And then here, instead of my label, that after Let's Go status underscore.

64
00:04:05,810 --> 00:04:07,670
Bar after.

65
00:04:08,060 --> 00:04:14,330
And let's go create loop to check the time every second.

66
00:04:18,300 --> 00:04:24,930
Let's say this, and, you know, for this status bar, maybe we want to put something more than just

67
00:04:24,930 --> 00:04:25,700
the time.

68
00:04:25,950 --> 00:04:30,990
So let's make this into an F string and just put this in quotation marks.

69
00:04:31,620 --> 00:04:34,110
And so this is going to be in brackets.

70
00:04:35,070 --> 00:04:37,440
And then we could go, what, like.

71
00:04:38,360 --> 00:04:40,070
Time elapsed.

72
00:04:41,750 --> 00:04:42,410
And like that.

73
00:04:42,800 --> 00:04:44,740
Yes, go ahead and save this and run it.

74
00:04:44,830 --> 00:04:46,520
Let's see what this looks like.

75
00:04:49,400 --> 00:04:51,980
Well, this over as songs you.

76
00:04:53,550 --> 00:05:00,290
And let's play this one and see down here, time elapsed, two seconds, three seconds, four seconds.

77
00:05:00,540 --> 00:05:06,120
And as this goes, you know, it'll say a minute and 10 seconds and then in 15 seconds, etc., as it

78
00:05:06,120 --> 00:05:06,690
goes along.

79
00:05:06,690 --> 00:05:08,700
So, OK, we are moving right along.

80
00:05:08,710 --> 00:05:09,780
This is looking pretty good.

81
00:05:10,050 --> 00:05:13,610
So in the next video, we'll start to talk about finding the total length of a song.

82
00:05:13,620 --> 00:05:15,280
It's actually a little bit harder than you would think.

83
00:05:15,510 --> 00:05:17,000
And we'll do that in the next video.
