Fonction Aléatoire pour URL
:salut:
Dans le but d'intégrer quelques musiques de fond aléatoirement dans un HTA en utilisant la balise bgsound
Code:
<bgsound src="http://URL/music.mp3">
J'ai opté a cette solution :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Function MusicAuHasard()
URL1 = "http://URL/Music1.mp3"
URL2 = "http://URL/Music2.mp3"
URL3 = "http://URL/Music3.mp3"
URL4 = "http://URL/Music4.mp3"
URL5 = "http://URL/Music5.mp3"
URL6 = "http://URL/Music6.mp3"
ListMusic = array(URL1,URL2,URL3,URL4,URL5,URL6)
Randomize
For i = 0 To UBound(ListMusic)
j = Int((UBound(ListMusic) - i + 1) * Rnd + i)
tmp = ListMusic(i)
ListMusic(i) = ListMusic(j)
ListMusic(j) = tmp
Next
MsgBox tmp,64,"Music au Hasard"
End Function
MusicAuHasard() |
Bon ce code marche et m'affiche bien le contenu dans un MsgBox, mais ce que je veux faire c'est comment modifier ma fonction pour récupérer une URL au hasard en l’appelant comme ceci tout en éliminant bien sûr le MsgBox :
Code:
<bgsound src="&MusicAuHasard()&">