
Un petit exemple de ce qu'on peut faire.
edit : je met un lien vers la source car la syntax ne s'affiche pas bien sur le forum
-> Mp3 Player <-
Toutes les fonction marche relativement bien.
Les fonction de save et load playlist ne sont pas codé.
Points noir, en barre des taches (donc mode minimizé), les checkbox "Shuffle" et "Repeat" ne sont pas pris en compte.
EDIT :
J'edite mon post principal pour y mettre une mise à jour, car ce post ainsi que mon script à plus d'un an...
Dans cette version, que j'ai intitulé "MPau3" mélange entre MP3 et le format .au3
 
 On peut le minimiser dans le tray, on peut bouger dans la chanson grâce a un slider, le mode aléatoire marche bien, de même que en boucle... enfin a priori. ^^
Les boutons suivant ">>" et précédent "<<" ne sont pas codé.
A amélioré pour ceux qui veulent.
Voici le code :
► Afficher le texteCode de MPau3
Code : Tout sélectionner
;~ Version d'Autoit : 3.2.12.1
;~ Auteur : Max5
;~ Programme : MPau3
;~ Version : 1.1
#include <GUIConstants.au3>
#include <IE.au3>
#include <INet.au3>
#Include <Date.au3>
#include <String.au3>
#Include <GuiTab.au3>
#include <File.au3>
#Include <Array.au3>
#Include <GuiEdit.au3>
#Include <GuiComboBox.au3>
#Include <GuiListBox.au3>
#include <Sound.au3>
#include <Constants.au3>
#Include <GuiSlider.au3>
$Form2 = GUICreate("MPau3", 597, 348, 340, 194)
GUISetBkColor(0x99B4D1)
$MoveBarre = GUICtrlCreateSlider(151, 43, 284, 20, BitOR($TBS_AUTOTICKS,$TBS_TOP,$TBS_LEFT))
GUICtrlSetCursor (-1, 0)
$MusicList = GUICtrlCreateList("", 50, 84, 545, 240)
$PlayButon = GUICtrlCreateButton("Play", 224, 0, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("Liste de musique :", 50, 67, 107, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("Volume", 4, 85, 45, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$StopButon = GUICtrlCreateButton("Stop", 312, 0, 75, 25, 0)
$BackButon = GUICtrlCreateButton("<<<", 136, 0, 75, 25, 0)
$ForwardButon = GUICtrlCreateButton(">>>", 400, 0, 75, 25, 0)
$vol100 = GUICtrlCreateRadio("100%", 0, 112, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol90 = GUICtrlCreateRadio("90%", 0, 131, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol80 = GUICtrlCreateRadio("80%", 0, 150, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol70 = GUICtrlCreateRadio("70%", 0, 169, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol60 = GUICtrlCreateRadio("60%", 0, 188, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol50 = GUICtrlCreateRadio("50%", 0, 207, 49, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol40 = GUICtrlCreateRadio("40%", 0, 226, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol30 = GUICtrlCreateRadio("30%", 0, 245, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol20 = GUICtrlCreateRadio("20%", 0, 264, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol10 = GUICtrlCreateRadio("10%", 0, 283, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$vol0 = GUICtrlCreateRadio("Mute", 0, 301, 49, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Shuffle = GUICtrlCreateCheckbox("Lecture aléatoire", 485, 22, 97, 13)
$Loop = GUICtrlCreateCheckbox("Lecture en boucle", 485, 3, 105, 17)
Dim $PBS_SMOOTH
$LenghBarre = GUICtrlCreateProgress(159, 66, 270, 17, $PBS_SMOOTH)
$MenuFichier = GUICtrlCreateMenu("&Fichier")
$MenuItem1 = GUICtrlCreateMenuItem("Ouvrir", $MenuFichier)
$SavePlaylist = GUICtrlCreateMenuItem("Sauver Playlist", $MenuFichier)
$HelpMenu = GUICtrlCreateMenu("&Aide")
$MenuItem2 = GUICtrlCreateMenuItem("A propos ...", $HelpMenu)
GUISetState(@SW_SHOW)
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)   
TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent")
While 1
    $msg = GUIGetMsg() 
    
    
    
    If $msg = $GUI_EVENT_CLOSE Then 
        If IsDeclared("qsound") Then
            _SoundClose($qsound)
        EndIf
        Exit
    EndIf
    
    
    
    If $msg = $GUI_EVENT_MINIMIZE Then 
        GuiSetState(@SW_HIDE)
        TraySetState(1)
        If IsDeclared("qsound") Then
            If _SoundStatus($qsound) = "paused" Or  _SoundStatus($qsound) = "playing" Then
                Dim $szDrive, $szDir, $szFName, $szExt
                $TestPath = _PathSplit(_GUICtrlListBox_GetText($MusicList, $IndexToPlay), $szDrive, $szDir, $szFName, $szExt)
                $ToolTip = "Playing : "&$szFName
            Else
                $ToolTip = "not playing"
            EndIf
        Else    
                $ToolTip = "not playing"
        EndIf   
        TraySetToolTip ("Cliquez ici pour restaurer MPau3"&@CRLF&$ToolTip)
    EndIf
    
    
    
    
    If $msg = $GUI_EVENT_MINIMIZE Then
        Dim $szDrive, $szDir, $szFName, $szExt
        $TestPath = _PathSplit(_GUICtrlListBox_GetText($MusicList, $IndexToPlay), $szDrive, $szDir, $szFName, $szExt)
        $ToolTip = "Playing : "&$szFName
    EndIf
    
    
    
    
    If $msg = $MenuItem2 Then
        MsgBox(64, "A propos...", "MPau3"&@CRLF&"Créer par Max5"&@CRLF&"Copyright 2008 ©")
    EndIf
    If $msg = $MenuItem1 Then
        $FileOpen = FileOpenDialog("Ouvrir un fichier audio...", "", "Audio (*.mp3;*.wav)", 1 + 4 )
        If $FileOpen <> "" Then
            If StringInStr($FileOpen, "|") > 0 Then
                $SelectionMultiple = StringSplit($FileOpen, "|")
                For $_zi = 2 To UBound($SelectionMultiple) - 1
                    _GUICtrlListBox_AddString($MusicList, $SelectionMultiple[1]&"\"&$SelectionMultiple[$_zi])
                Next
            Else    
                _GUICtrlListBox_AddString($MusicList, $FileOpen)
            EndIf
        EndIf
    EndIf
    
    
    
    
    
    
    
    If $msg = $PlayButon Then
        If _GUICtrlListBox_GetText($MusicList, 0) <> "" Then
            If GUICtrlRead($PlayButon) = "Play" Then 
                GUICtrlSetData($PlayButon, "Pause")
            ElseIf GUICtrlRead($PlayButon) = "Pause" Then 
                GUICtrlSetData($PlayButon, "Play")
            EndIf
        EndIf
        If IsDeclared("qsound") Then
            $IndexCompare = _GUICtrlListBox_GetCurSel($MusicList)
            If _SoundStatus($qsound) = "playing" And $IndexCompare = $IndexToPlay Then
                _SoundPause($qsound)
            ElseIf _SoundStatus($qsound) = "paused" And $IndexCompare = $IndexToPlay Then
                _SoundResume($qsound)
            Else
                _SoundClose($qsound)
                Global $IndexToPlay = _GUICtrlListBox_GetCurSel($MusicList)
                If $IndexToPlay <> -1 Then
                    $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, $IndexToPlay))
                    _SoundPlay($qsound)
                Else
                    Global $IndexToPlay = 0
                    _GUICtrlListBox_SetCurSel($MusicList, 0)
                    $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, 0))
                    _SoundPlay($qsound)
                EndIf
            EndIf       
        Else
            Global $IndexToPlay = _GUICtrlListBox_GetCurSel($MusicList)
            If $IndexToPlay <> -1 Then
                $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, $IndexToPlay))
                _SoundPlay($qsound)
            Else
                Global $IndexToPlay = 0
                _GUICtrlListBox_SetCurSel($MusicList, 0)
                $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, 0))
                _SoundPlay($qsound)
            EndIf
        EndIf
    EndIf
    
    
    
    
    
    If $msg = $StopButon And IsDeclared("qsound") Then
        If _SoundStatus($qsound) = "paused" Or  _SoundStatus($qsound) = "playing" Then
            GUICtrlSetData($PlayButon, "Play")
            GUICtrlSetData($LenghBarre, 0)
            _SoundClose($qsound)
        EndIf
    EndIf
    
    
    
    
    
    If GUICtrlRead($vol100) = 1 Then
        SoundSetWaveVolume(100)
    ElseIf GUICtrlRead($vol90) = 1 Then
        SoundSetWaveVolume(90)
    ElseIf GUICtrlRead($vol80) = 1 Then
        SoundSetWaveVolume(80)
    ElseIf GUICtrlRead($vol70) = 1 Then
        SoundSetWaveVolume(70)
    ElseIf GUICtrlRead($vol60) = 1 Then
        SoundSetWaveVolume(60)
    ElseIf GUICtrlRead($vol50) = 1 Then
        SoundSetWaveVolume(50)
    ElseIf GUICtrlRead($vol40) = 1 Then
        SoundSetWaveVolume(40)
    ElseIf GUICtrlRead($vol30) = 1 Then
        SoundSetWaveVolume(30)
    ElseIf GUICtrlRead($vol20) = 1 Then
        SoundSetWaveVolume(20)
    ElseIf GUICtrlRead($vol10) = 1 Then
        SoundSetWaveVolume(10)
    ElseIf GUICtrlRead($vol0) = 1 Then
        SoundSetWaveVolume(0)
    EndIf
    
    
    
    
    If $msg = $MoveBarre Then
        If IsDeclared("qsound") Then
            If _SoundStatus($qsound) = "playing" Then
                $SongLengh = _SoundLength($qsound, 2)
                $SongAvancement = GUICtrlRead($MoveBarre)
                $TicksAvancement = ($SongAvancement * $SongLengh) / 100
                Dim $Secs, $Mins, $Hour
                $TicksAvancementH24 = _TicksToTime($TicksAvancement, $Hour, $Mins, $Secs )
                _SoundSeek($qsound, $Hour, $Mins, $Secs)
                _SoundPlay($qsound)
            EndIf
        EndIf
    EndIf
    
    
    
    If IsDeclared("qsound") Then
        If _SoundStatus($qsound) = "playing" Then
            $TotalLengh = _SoundLength($qsound, 2)
            $CurrentLengh = _SoundPos($qsound, 2)
            $PercentLengh = ($CurrentLengh * 100) / $TotalLengh
            GUICtrlSetData($LenghBarre, $PercentLengh)
            If $CurrentLengh >= ($TotalLengh - 500) Then
                _SoundClose($qsound)
                GUICtrlSetData($LenghBarre, 0)
                GUICtrlSetData($PlayButon, "Play")
                If $IndexToPlay <> (_GUICtrlListBox_GetCount($MusicList) - 1) Then
                    If GUICtrlRead($Shuffle) <> 1 Then
                        _SoundClose($qsound)
                        $OldIndex = $IndexToPlay 
                        Global $IndexToPlay = ($OldIndex + 1)
                        _GUICtrlListBox_SetCurSel($MusicList, $IndexToPlay)
                        $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, $IndexToPlay))
                        _SoundPlay($qsound)
                        GUICtrlSetData($PlayButon, "Pause")
                            Dim $szDrive, $szDir, $szFName, $szExt
                            $TestPath = _PathSplit(_GUICtrlListBox_GetText($MusicList, $IndexToPlay), $szDrive, $szDir, $szFName, $szExt)
                            $ToolTip = "Playing : "&$szFName
                            TraySetToolTip ("Cliquez ici pour restaurer MPau3"&@CRLF&$ToolTip)
                    EndIf
                EndIf
                If $IndexToPlay <> (_GUICtrlListBox_GetCount($MusicList) - 1) And GUICtrlRead($Shuffle) = 1 Then
                    _SoundClose($qsound)
                    $OldIndex = $IndexToPlay
                    Do
                        Global $IndexToPlay = Random(0,(_GUICtrlListBox_GetCount($MusicList) - 1),1)
                    Until $IndexToPlay <> $OldIndex
                    _GUICtrlListBox_SetCurSel($MusicList, $IndexToPlay)
                    $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, $IndexToPlay))
                    _SoundPlay($qsound)
                    GUICtrlSetData($PlayButon, "Pause")
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $TestPath = _PathSplit(_GUICtrlListBox_GetText($MusicList, $IndexToPlay), $szDrive, $szDir, $szFName, $szExt)
                        $ToolTip = "Playing : "&$szFName
                        TraySetToolTip ("Cliquez ici pour restaurer MPau3"&@CRLF&$ToolTip)
                EndIf
                If $IndexToPlay = (_GUICtrlListBox_GetCount($MusicList) - 1) Then
                    If GUICtrlRead($Loop) = 1 Then
                        _SoundClose($qsound)
                        Global $IndexToPlay = 0
                        _GUICtrlListBox_SetCurSel($MusicList, 0)
                        $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, 0))
                        _SoundPlay($qsound)
                        GUICtrlSetData($PlayButon, "Pause")
                            Dim $szDrive, $szDir, $szFName, $szExt
                            $TestPath = _PathSplit(_GUICtrlListBox_GetText($MusicList, $IndexToPlay), $szDrive, $szDir, $szFName, $szExt)
                            $ToolTip = "Playing : "&$szFName
                            TraySetToolTip ("Cliquez ici pour restaurer MPau3"&@CRLF&$ToolTip)
                    EndIf
                EndIf
                If $IndexToPlay = (_GUICtrlListBox_GetCount($MusicList) - 1) Then
                    If GUICtrlRead($Shuffle) = 1 And GUICtrlRead($Loop) = 1 Then
                        _SoundClose($qsound)
                        Global $IndexToPlay = Random(0,(_GUICtrlListBox_GetCount($MusicList) - 2),1)
                        _GUICtrlListBox_SetCurSel($MusicList, $IndexToPlay)
                        $qsound = _SoundOpen(_GUICtrlListBox_GetText($MusicList, $IndexToPlay))
                        _SoundPlay($qsound)
                        GUICtrlSetData($PlayButon, "Pause")
                            Dim $szDrive, $szDir, $szFName, $szExt
                            $TestPath = _PathSplit(_GUICtrlListBox_GetText($MusicList, $IndexToPlay), $szDrive, $szDir, $szFName, $szExt)
                            $ToolTip = "Playing : "&$szFName
                            TraySetToolTip ("Cliquez ici pour restaurer MPau3"&@CRLF&$ToolTip)
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    
    
    
    
WEnd
Func SpecialEvent()
        GuiSetState(@SW_Show)
        TraySetState(2)
EndFunc
 



 
 
 
  









