Code : Tout sélectionner
#include <GUIConstants.au3>
#include <Sound.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("leteur de musique en autoit", 498, 371, 193, 126)
$Button1 = GUICtrlCreateButton("ouvrir...", 48, 48, 161, 65)
GUICtrlSetFont(-1, 16, 800, 0, "Arial Black")
$Label1 = GUICtrlCreateLabel("chemin :", 24, 136, 445, 63)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Black")
$Button2 = GUICtrlCreateButton("jouer | mettre en pause", 232, 48, 177, 65)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Black")
$Label2 = GUICtrlCreateLabel("volume:", 112, 288, 94, 34)
GUICtrlSetFont(-1, 16, 800, 0, "Arial Black")
$Button5 = GUICtrlCreateButton("Mettre ce son en favoris", 40, 208, 200, 50, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Black")
$Button6 = GUICtrlCreateButton("Jouer le son favoris", 250, 208, 200, 50, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Black")
$Button3 = GUICtrlCreateButton("-", 224, 280, 49, 49, 0)
GUICtrlSetFont(-1, 16, 800, 0, "Arial Black")
$Button4 = GUICtrlCreateButton("+", 280, 280, 49, 49, 0)
GUICtrlSetFont(-1, 16, 800, 0, "Arial Black")
$Label3 = GUICtrlCreateLabel("poid du son sur votre disque dur :", 8, 336, 480, 22)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Black")
GUICtrlSetState($Button3,$GUI_ENABLE)
GUICtrlSetState($Button4,$GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$size= ""
$source = ""
$sound = 0
$vol = 100
$volume = ""
While 1
$nMsg = GUIGetMsg()
$volume = volume($vol)
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$source = FileOpenDialog("ouvrir",@MyDocumentsDir&'\',"mp3 (*.mp3)",9)
GUICtrlSetData($Label1,"Chemin : "& $source)
If $source = "" Then MsgBox(16,"leteur de musique en autoit","Erreur, aucun son n'a été choisis !")
If $source <> "" Then
$size = FileGetSize($source)
GUICtrlSetData($Label3,"poid du son sur votre disque dur : "& $size & " bytes")
EndIf
Case $Button2
If $sound = 0 Then
$sound = _SoundOpen($source)
_SoundPlay($sound)
ElseIf _SoundStatus($sound) = "paused" Then
_SoundResume($sound)
Else
_SoundPause($sound)
EndIf
Case $Button5
If $source = "" Then MsgBox(16,"leteur de musique en autoit","Erreur, aucun son n'a été choisis !")
If $source <> "" Then
FileDelete(@ScriptDir&"\fav.txt")
FileWrite(@ScriptDir&"\fav.txt", $source)
MsgBox(64,"leteur de musique en autoit","Votre son à été marqué comme favoris.")
EndIf
Case $Button6
$source = FileRead(@ScriptDir&"\fav.txt")
If FileExists(@ScriptDir&"\fav.txt") = 0 Then MsgBox(16,"leteur de musique en autoit","Erreur, aucun son n'est définis comme favoris !")
If FileExists(@ScriptDir&"\fav.txt") = 1 Then
If FileExists($source) = 0 Then MsgBox(16,"leteur de musique en autoit","Erreur, le son définis comme favoris n'existe pas ou plus !")
If FileExists($source) = 1 Then
$sound = 0
GUICtrlSetData($Label1,"Chemin : "& $source)
$sound = $source
SoundPlay($sound)
EndIf
EndIf
If $source = "" Then MsgBox(16,"leteur de musique en autoit","Erreur, aucun son n'a été choisis !")
If $source <> "" Then
$size = FileGetSize($source)
GUICtrlSetData($Label3,"poid du son sur votre disque dur : "& $size & " bytes")
EndIf
Case $Button3, $Button4
Local $step = 5
If $nMsg = $Button3 Then $step = -$step
$vol = $vol + $step
GUICtrlSetState($Button3,$GUI_ENABLE)
GUICtrlSetState($Button4,$GUI_ENABLE)
If $vol = 0 Then GUICtrlSetState($Button3,$GUI_DISABLE)
If $vol = 100 Then GUICtrlSetState($Button4,$GUI_DISABLE)
Case Else
If $sound <> 0 And _SoundPos($sound, 2) >= _SoundLength($sound, 2) Then
_SoundClose($sound)
$sound = 0
EndIf
EndSwitch
WEnd
Func volume ($vol)
Return SoundSetWaveVolume($vol)
EndFunc