1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
| ' Gambas class file
PUBLIC hTrigTimer AS NEW Timer AS "_hTrigTimer" PUBLIC hTrayIcon AS NEW TrayIcon AS "_hTrayIcon" PUBLIC sPathFile AS STRING = User.Home & "/Musique/Jukebox/" PUBLIC sPathFileAudio AS String[] PUBLIC iIndexFileAudio AS Integer[] PUBLIC sString[2] AS STRING PUBLIC iIndex AS INTEGER PUBLIC iTemp AS INTEGER PUBLIC iReserv AS INTEGER
PUBLIC SUB Form_Open()
hTrigTimer.delay = 1 hTrigTimer.Trigger hTrayIcon.Picture = Picture[Application.path & "/iJukebox24.png"] hTrayIcon.Show END
PUBLIC SUB Form_Deactivate() ME.Hide END
PUBLIC SUB _hTrayIcon_MouseUp()
ME.X = hTrayIcon.ScreenX ME.visible = NOT ME.visible END
PUBLIC SUB _hTrigTimer_Timer() SELECT CASE hTrigTimer.Delay CASE 1 ME.Visible = FALSE hTrigTimer.delay = 1000 _load RETURN CASE 1000 IF (Int(Music.Pos) = 0) THEN 'Détection de Fin de Plage hTrigTimer.Enabled = FALSE TextBox2.Text = "00:00" _MusicPlay ELSE INC iTemp TextBox2.Text = Format$(iTemp DIV 60, "00") & ":" & Format$(iTemp MOD 60, "00") ProgressBar1.Value = (iTemp / ((sString[0] * 60) + sString[1])) ENDIF END SELECT END
PUBLIC SUB _load()
sPathFileAudio = RDir(sPathFile, "*.{ogg,mp3,Wav}") 'Charge la Liste iIndexFileAudio = NEW INTEGER[sPathFileAudio.Count] 'Redimentionne le Tableau d'Index WHILE iIndex < sPathFileAudio.Count 'Charge le Tableau d'Index iIndexFileAudio[iIndex] = iIndex INC iIndex WEND END
PUBLIC SUB _MusicPlay() 'Lecture Aléatoire de la Liste sans Répétition.
DIM iRnd AS INTEGER IF (iReserv = 0) THEN iReserv = iIndex - 1 'Si la liste Terminée, on y Retourne. iRnd = Int(Rnd(iReserv)) SWAP iIndexFileAudio[iRnd], iIndexFileAudio[iReserv] TextBox1.Text = sPathFileAudio[iIndexFileAudio[iReserv]] _ExtractTime Label1.Text = Format$(sString[0], "00") & ":" & Format$(sString[1], "00") Music.Load(sPathFile & TextBox1.Text) Music.play iTemp = 0 hTrigTimer.Enabled = TRUE DEC iReserv END
PUBLIC SUB _ExtractTime() DIM sInfoTime, sDetailTime AS STRING
EXEC ["mediainfo", sPathFile & TextBox1.Text] TO sInfoTime PRINT "sInfoTime";; sInfoTime FOR EACH sInfoTime IN Split(sInfoTime, "\n") IF InStr(sInfoTime, "Duration") THEN FOR EACH sDetailTime IN Scan(sInfoTime, "*:*mn*s") sString[0] = sString[1] sString[1] = sDetailTime NEXT RETURN ENDIF NEXT END PUBLIC SUB Command_Click()
SELECT CASE LAST.Tag CASE 1 'Start/Change Music.Stop TextBox2.Text = "00:00" Button2.Enabled = TRUE Button3.Picture = Picture["icon:/22/pause"] Button3.Enabled = TRUE _MusicPlay CASE 2 'Stop hTrigTimer.Enabled = FALSE Button2.Enabled = FALSE Button3.Enabled = FALSE TextBox1.Text = "Click Start/Change" TextBox2.Text = "00:00" Label1.Text = TextBox2.Text ProgressBar1.Value = 0 Music.Stop CASE 3 'Play/Pause SELECT CASE LAST.Picture CASE Picture["icon:/22/pause"] LAST.Picture = Picture["icon:/22/play"] Music.Pause hTrigTimer.Enabled = FALSE CASE Picture["icon:/22/play"] LAST.Picture = Picture["icon:/22/pause"] Music.Play hTrigTimer.Enabled = TRUE END SELECT END SELECT END
|