Sign in to follow this  
Followers 0
NEO12

problem with next and previous function in mp3 player

3 posts in this topic

#1 ·  Posted (edited)

hello everybody

i'm trying to make an mp3 player but i'm encountering a few problems with the next and previous function ( next song and previous song).

The problem is at the end of the code. The language of the buttons in the script is french.

Here is the code:

#NoTrayIcon
#include <WindowsConstants.au3>
#include <SliderConstants.au3>
#include <ProgressConstants.au3>
#include <ListBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <Sound.au3>
#include <GUIConstants.au3>
#Include <GuiListBox.au3>
#include <file.au3>
#include <array.au3>


SplashImageOn("",@ScriptDir&"\splash.bmp","400","500","-1","-1",3)
Sleep(3000)
SplashOff()
$Mp3PlayerGui = GUICreate("White Tiger MP3 Player", 420, 600, 272, 170)
GUISetBkColor(0x000000)
$img = GUICtrlCreatePic(@ScriptDir & "\tiger.jpg",80,280,250,304)
$Open = GUICtrlCreateButton("Ouvrir...", 3, 2, 65, 21, 0)
$Label2 = GUICtrlCreateLabel("Volume :", 8, 32, 61, 17)
GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
GUICtrlSetColor(-1,0xFFFFFF)
$Labelvol = GUICtrlCreateLabel("100%", 12, 50, 61, 17)
GUICtrlSetColor(-1,0xFFFFFF)
$Labelvolmin= GUICtrlCreateLabel("0%", 16, 250, 61, 17)
GUICtrlSetColor(-1,0xFFFFFF)
$slider = GUICtrlCreateSlider(8, 65, 49, 180, BitOR($TBS_VERT, $TBS_AUTOTICKS))
GUICtrlSetLimit($slider, 100, 0)
GUICtrlSetData($slider, 50)
GUICtrlSetBkColor(-1,0x000000)
$Input1 = GUICtrlCreateInput("", 292, 7, 81, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetBKColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label3 = GUICtrlCreateLabel("Durée :", 240, 12, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xFFFFFF)
$Play = GUICtrlCreateButton("Lire  >", 128, 39, 57, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PosSong = GUICtrlCreateProgress(121, 67, 238, 14, $PBS_SMOOTH)
GUICtrlSetBKColor(-1, 0x97d1fd)
GUICtrlSetData(-1, 25)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
$Button1 = GUICtrlCreateButton("Pause/Lire", 196, 39, 73, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Stop", 279, 39, 57, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PlayList = GUICtrlCreateList("", 60, 87, 317, 136, BitOR($WS_HSCROLL,$WS_VSCROLL,$WS_BORDER))
GUICtrlSetData(-1, "")
GUICtrlSetColor(-1, 0xFFFFE1)
GUICtrlSetBkColor(-1, 0x808080)
$Label1 = GUICtrlCreateLabel("Playlist :", 60, 65, 42, 17)
$Label4 = GUICtrlCreateLabel("Fichier:", 73, 12, 45, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1,0xFFFFFF)
$Input2 = GUICtrlCreateInput("", 125, 7, 110, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetBKColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$MoveBack = GUICtrlCreateButton("<<", 100, 65, 19, 18)
$MoveForward = GUICtrlCreateButton(">>", 361, 65, 19, 18)
$Button4 = GUICtrlCreateButton("Effacer liste", 60, 223, 150, 27, 0)
$Button5 = GUICtrlCreateButton("Retirer ", 210, 223, 110, 27, 0)
$Shuffle = GUICtrlCreateCheckbox  ("Shuffle", 324, 223, 52, 12)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetColor(-1,0xFFFFFF)
$Repeat = GUICtrlCreateCheckbox  ("Repeat", 324, 237, 53, 12)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)





GUICtrlSetData($PosSong, 0)

Global $old_slider_value = 50
While 1
    $msg = GUIGetMsg()
    $slider_value = GUICtrlRead($slider)

    Select
Case $msg = $GUI_EVENT_CLOSE
            global $SoundToPlay
            If IsDeclared($SoundToPlay) Then _SoundClose($SoundToPlay)
            ExitLoop
        Case $msg = $Open
            If _GUICtrlListBox_GetText($PlayList, 0) <> "" Then
                $LastItem = _GUICtrlListBox_GetCount($PlayList)
                $Local = _GUICtrlListBox_GetText($PlayList, $LastItem - 1)
            ElseIf FileExists(@HomeDrive & "") Then
                $Local = @HomeDrive & ""
            ElseIf FileExists(@HomeDrive & "") Then
                $Local = @HomeDrive & ""
            Else
                $Local = @DesktopDir
            EndIf
            $PathToMp3 = FileOpenDialog("Fichier audio à ouvrir...", $Local, "Audio (*.mp3)", 5)
            If StringInStr($PathToMp3, "|") > 0 Then
                $MultiSelect = StringSplit($PathToMp3, "|")
                For $NbrSongs = 2 To UBound($MultiSelect) - 1
                    _GUICtrlListBox_AddString($PlayList, $MultiSelect[1]&"\"&$MultiSelect[$NbrSongs])
                Next
            Else
                If $PathToMp3 <> "" Then
                _GUICtrlListBox_AddString($PlayList, $PathToMp3)
                EndIf
            EndIf

            If Not IsDeclared("SoundToPlay") Then
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, 0)
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            ElseIf IsDeclared("SoundToPlay") Then
                If _SoundStatus($SoundToPlay) <> "playing" And _SoundStatus($SoundToPlay) <> "paused" Then
                    _SoundClose($SoundToPlay)
                    $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                    GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                    _GUICtrlListBox_SetCurSel($PlayList, 0)
                    Dim $szDrive, $szDir, $szFName, $szExt
                    $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                    GUICtrlSetData($Input2, $NameSong[3])
                    _SoundPlay($SoundToPlay, 0)
                    GUICtrlSetData($PosSong, 0)
                EndIf
            EndIf
        Case $msg = $Play
            If IsDeclared("SoundToPlay") Then
                _SoundStop($SoundToPlay)
                _SoundClose($SoundToPlay)
            EndIf
            If _GUICtrlListBox_GetCurSel($PlayList) <> $LB_ERR Then
            $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, _GUICtrlListBox_GetCurSel($PlayList)))
            GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
            _GUICtrlListBox_SetCurSel($PlayList, _GUICtrlListBox_GetCurSel($PlayList))
            Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, _GUICtrlListBox_GetCurSel($PlayList)), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
            _SoundPlay($SoundToPlay, 0)
            GUICtrlSetData($PosSong, 0)
            Else
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, 0)
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            EndIf
        Case $msg = $Button1 And IsDeclared("SoundToPlay")
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                _SoundPause($SoundToPlay)
            ElseIf IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "paused" Then
                _SoundResume($SoundToPlay)
            EndIf
        Case $msg = $Button2 And IsDeclared("SoundToPlay")
            _SoundStop($SoundToPlay)
            _SoundClose($SoundToPlay)
            GUICtrlSetData($PosSong, 0)
        Case $old_slider_value <> $slider_value
            SoundSetWaveVolume(100 - $slider_value)
            $old_slider_value = $slider_value
        Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing"
            $TempsTotalSong = _SoundLength($SoundToPlay, 2)
            $LectureAvancement = _SoundPos($SoundToPlay, 2)
            $percent = ($LectureAvancement * 100) / $TempsTotalSong
            GUICtrlSetData($PosSong, $percent)
            If $LectureAvancement = $TempsTotalSong Then
                GUICtrlSetData($PosSong, 0)
            EndIf
        Case $msg = $Button4
            _GUICtrlListBox_ResetContent($PlayList)
        Case $msg = $Button5 And _GUICtrlListBox_GetCurSel($PlayList) <> $LB_ERR
            _GUICtrlListBox_DeleteString($PlayList, _GUICtrlListBox_GetCurSel($PlayList))
        Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing"
            $TempsTotalSong = _SoundLength($SoundToPlay, 2)
            $LectureAvancement = _SoundPos($SoundToPlay, 2)
            $CurrentIndexPlay = _GUICtrlListBox_GetCurSel($PlayList)
            $NbrSongsInPlayList = _GUICtrlListBox_GetCount($PlayList) - 1
            If $CurrentIndexPlay <> $NbrSongsInPlayList Then
                If $LectureAvancement = $TempsTotalSong Then
                    _SoundStop($SoundToPlay)
                    _SoundClose($SoundToPlay)
                    Sleep(500)
                If ControlCommand("", "", $Shuffle, "IsChecked", "") = 0 Then
                    $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $CurrentIndexPlay + 1))
                    GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                    _GUICtrlListBox_SetCurSel($PlayList, $CurrentIndexPlay + 1)
                    Dim $szDrive, $szDir, $szFName, $szExt
                    $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $CurrentIndexPlay + 1), $szDrive, $szDir, $szFName, $szExt)
                    GUICtrlSetData($Input2, $NameSong[3])
                    _SoundPlay($SoundToPlay, 0)
                    GUICtrlSetData($PosSong, 0)
                Else
                    $IndexShuffle = Random(0, $NbrSongsInPlayList, 1)
                        If $IndexShuffle = $CurrentIndexPlay Then $IndexShuffle = $CurrentIndexPlay + 3
                    $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $IndexShuffle))
                    GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                    _GUICtrlListBox_SetCurSel($PlayList, $IndexShuffle)
                    Dim $szDrive, $szDir, $szFName, $szExt
                    $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $IndexShuffle), $szDrive, $szDir, $szFName, $szExt)
                    GUICtrlSetData($Input2, $NameSong[3])
                    _SoundPlay($SoundToPlay, 0)
                    GUICtrlSetData($PosSong, 0)
                EndIf
                EndIf
            EndIf

            If $CurrentIndexPlay = $NbrSongsInPlayList Then
                If $LectureAvancement = $TempsTotalSong Then
                    _SoundStop($SoundToPlay)
                    _SoundClose($SoundToPlay)
                    Sleep(500)
                    If ControlCommand("", "", $Repeat, "IsChecked", "") = 1 And ControlCommand("", "", $Shuffle, "IsChecked", "") = 0 Then
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList,  0)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList,  0), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    ElseIf ControlCommand("", "", $Repeat, "IsChecked", "") = 1 And ControlCommand("", "", $Shuffle, "IsChecked", "") = 1 Then
                        $IndexShuffle = Random(0, $NbrSongsInPlayList, 1)
                        If $IndexShuffle = $CurrentIndexPlay Then $IndexShuffle = $CurrentIndexPlay + 3
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $IndexShuffle))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $IndexShuffle)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $IndexShuffle), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    EndIf
                EndIf
            EndIf
;Here is my problem:
        Case $msg = $MoveForward And IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing"
            $LectureAvancement = _SoundPos($SoundToPlay, 2) / 1000
            _SoundSeek($SoundToPlay, 0, 0, $LectureAvancement + 5)
            _SoundPlay($SoundToPlay, 0)
        Case $msg = $MoveBack And IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing"
            $LectureAvancement = _SoundPos($SoundToPlay, 2) / 1000
            _SoundSeek($SoundToPlay, 0, 0, $LectureAvancement - 1 )
            _SoundPlay($SoundToPlay, 0)
    EndSelect
WEnd
Here is a preview:

post-50902-12514630671259_thumb.jpg

Thanks for the uture help.

Edited by NEO12

Share this post


Link to post
Share on other sites



NEO12,

In my opinion, you need to rethink your main While...WEnd loop and alter a lot of the Case statements. For example, you have 2 examples of :

Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing"

As this will be true whenever you are playing a file, nothing below the first example will ever trigger as the Select will be satisfied at that point.

I would strongly advise that you use only the actual controls as Case statements in the While...WEnd loop and then have If statements to see if the various other parameters are met. At least that way you will see that the controls are being activated and debugging will become easier.

In the following code I have moved (slightly amended as I suggested above) versions of your $MoveForward and $MoveBack Case statements ahead of the "always true" Case and they now function as designed:

#NoTrayIcon
#include <WindowsConstants.au3>
#include <SliderConstants.au3>
#include <ProgressConstants.au3>
#include <ListBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <Sound.au3>
#include <GUIConstants.au3>
#include <GuiListBox.au3>
#include <file.au3>
#include <array.au3>


SplashImageOn("", @ScriptDir & "\splash.bmp", "400", "500", "-1", "-1", 3)
Sleep(3000)
SplashOff()
$Mp3PlayerGui = GUICreate("White Tiger MP3 Player", 420, 600, 272, 170)
GUISetBkColor(0x000000)
$img = GUICtrlCreatePic(@ScriptDir & "\tiger.jpg", 80, 280, 250, 304)
$Open = GUICtrlCreateButton("Ouvrir...", 3, 2, 65, 21, 0)
$Label2 = GUICtrlCreateLabel("Volume :", 8, 32, 61, 17)
GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Labelvol = GUICtrlCreateLabel("100%", 12, 50, 61, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Labelvolmin = GUICtrlCreateLabel("0%", 16, 250, 61, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$slider = GUICtrlCreateSlider(8, 65, 49, 180, BitOR($TBS_VERT, $TBS_AUTOTICKS))
GUICtrlSetLimit($slider, 100, 0)
GUICtrlSetData($slider, 50)
GUICtrlSetBkColor(-1, 0x000000)
$Input1 = GUICtrlCreateInput("", 292, 7, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label3 = GUICtrlCreateLabel("Durée :", 240, 12, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Play = GUICtrlCreateButton("Lire  >", 128, 39, 57, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PosSong = GUICtrlCreateProgress(121, 67, 238, 14, $PBS_SMOOTH)
GUICtrlSetBkColor(-1, 0x97d1fd)
GUICtrlSetData(-1, 25)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
$Button1 = GUICtrlCreateButton("Pause/Lire", 196, 39, 73, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Stop", 279, 39, 57, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PlayList = GUICtrlCreateList("", 60, 87, 317, 136, BitOR($WS_HSCROLL, $WS_VSCROLL, $WS_BORDER))
GUICtrlSetData(-1, "")
GUICtrlSetColor(-1, 0xFFFFE1)
GUICtrlSetBkColor(-1, 0x808080)
$Label1 = GUICtrlCreateLabel("Playlist :", 60, 65, 42, 17)
$Label4 = GUICtrlCreateLabel("Fichier:", 73, 12, 45, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input2 = GUICtrlCreateInput("", 125, 7, 110, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$MoveBack = GUICtrlCreateButton("<<", 100, 65, 19, 18)
$MoveForward = GUICtrlCreateButton(">>", 361, 65, 19, 18)
$Button4 = GUICtrlCreateButton("Effacer liste", 60, 223, 150, 27, 0)
$Button5 = GUICtrlCreateButton("Retirer ", 210, 223, 110, 27, 0)
$Shuffle = GUICtrlCreateCheckbox("Shuffle", 324, 223, 52, 12)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetColor(-1, 0xFFFFFF)
$Repeat = GUICtrlCreateCheckbox("Repeat", 324, 237, 53, 12)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)





GUICtrlSetData($PosSong, 0)

Global $old_slider_value = 50
While 1
    $msg = GUIGetMsg()
    $slider_value = GUICtrlRead($slider)

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Global $SoundToPlay
            If IsDeclared($SoundToPlay) Then _SoundClose($SoundToPlay)
            ExitLoop
        Case $msg = $Open
            If _GUICtrlListBox_GetText($PlayList, 0) <> "" Then
                $LastItem = _GUICtrlListBox_GetCount($PlayList)
                $Local = _GUICtrlListBox_GetText($PlayList, $LastItem - 1)
            ElseIf FileExists(@HomeDrive & "") Then
                $Local = @HomeDrive & ""
            ElseIf FileExists(@HomeDrive & "") Then
                $Local = @HomeDrive & ""
            Else
                $Local = @DesktopDir
            EndIf
            $PathToMp3 = FileOpenDialog("Fichier audio à ouvrir...", $Local, "Audio (*.mp3)", 5)
            If StringInStr($PathToMp3, "|") > 0 Then
                $MultiSelect = StringSplit($PathToMp3, "|")
                For $NbrSongs = 2 To UBound($MultiSelect) - 1
                    _GUICtrlListBox_AddString($PlayList, $MultiSelect[1] & "\" & $MultiSelect[$NbrSongs])
                Next
            Else
                If $PathToMp3 <> "" Then
                    _GUICtrlListBox_AddString($PlayList, $PathToMp3)
                EndIf
            EndIf

            If Not IsDeclared("SoundToPlay") Then
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, 0)
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            ElseIf IsDeclared("SoundToPlay") Then
                If _SoundStatus($SoundToPlay) <> "playing" And _SoundStatus($SoundToPlay) <> "paused" Then
                    _SoundClose($SoundToPlay)
                    $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                    GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                    _GUICtrlListBox_SetCurSel($PlayList, 0)
                    Dim $szDrive, $szDir, $szFName, $szExt
                    $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                    GUICtrlSetData($Input2, $NameSong[3])
                    _SoundPlay($SoundToPlay, 0)
                    GUICtrlSetData($PosSong, 0)
                EndIf
            EndIf
        Case $msg = $Play
            If IsDeclared("SoundToPlay") Then
                _SoundStop($SoundToPlay)
                _SoundClose($SoundToPlay)
            EndIf
            If _GUICtrlListBox_GetCurSel($PlayList) <> $LB_ERR Then
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, _GUICtrlListBox_GetCurSel($PlayList)))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, _GUICtrlListBox_GetCurSel($PlayList))
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, _GUICtrlListBox_GetCurSel($PlayList)), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            Else
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, 0)
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            EndIf
        Case $msg = $Button1 And IsDeclared("SoundToPlay")
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                _SoundPause($SoundToPlay)
            ElseIf IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "paused" Then
                _SoundResume($SoundToPlay)
            EndIf
        Case $msg = $Button2 And IsDeclared("SoundToPlay")
            _SoundStop($SoundToPlay)
            _SoundClose($SoundToPlay)
            GUICtrlSetData($PosSong, 0)
        Case $old_slider_value <> $slider_value
            SoundSetWaveVolume(100 - $slider_value)
            $old_slider_value = $slider_value
        Case $msg = $Button4
            _GUICtrlListBox_ResetContent($PlayList)
        Case $msg = $Button5 And _GUICtrlListBox_GetCurSel($PlayList) <> $LB_ERR
            _GUICtrlListBox_DeleteString($PlayList, _GUICtrlListBox_GetCurSel($PlayList))
        Case $msg = $MoveForward   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New version
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                $LectureAvancement = _SoundPos($SoundToPlay, 2) / 1000
                _SoundSeek($SoundToPlay, 0, 0, $LectureAvancement + 5)
                _SoundPlay($SoundToPlay, 0)
            EndIf
        Case $msg = $MoveBack   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New version
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                $LectureAvancement = _SoundPos($SoundToPlay, 2) / 1000
                _SoundSeek($SoundToPlay, 0, 0, $LectureAvancement - 1)
                _SoundPlay($SoundToPlay, 0)
            EndIf
        Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" ; <<<<<<<<<<<<<< This is the same
            $TempsTotalSong = _SoundLength($SoundToPlay, 2)
            $LectureAvancement = _SoundPos($SoundToPlay, 2)
            $percent = ($LectureAvancement * 100) / $TempsTotalSong
            GUICtrlSetData($PosSong, $percent)
            If $LectureAvancement = $TempsTotalSong Then
                GUICtrlSetData($PosSong, 0)
            EndIf
        Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" ; <<<<<<<<<<<<<< As this!!!!!!!!!
            $TempsTotalSong = _SoundLength($SoundToPlay, 2)
            $LectureAvancement = _SoundPos($SoundToPlay, 2)
            $CurrentIndexPlay = _GUICtrlListBox_GetCurSel($PlayList)
            $NbrSongsInPlayList = _GUICtrlListBox_GetCount($PlayList) - 1
            If $CurrentIndexPlay <> $NbrSongsInPlayList Then
                If $LectureAvancement = $TempsTotalSong Then
                    _SoundStop($SoundToPlay)
                    _SoundClose($SoundToPlay)
                    Sleep(500)
                    If ControlCommand("", "", $Shuffle, "IsChecked", "") = 0 Then
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $CurrentIndexPlay + 1))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $CurrentIndexPlay + 1)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $CurrentIndexPlay + 1), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    Else
                        $IndexShuffle = Random(0, $NbrSongsInPlayList, 1)
                        If $IndexShuffle = $CurrentIndexPlay Then $IndexShuffle = $CurrentIndexPlay + 3
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $IndexShuffle))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $IndexShuffle)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $IndexShuffle), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    EndIf
                EndIf
            EndIf

            If $CurrentIndexPlay = $NbrSongsInPlayList Then
                If $LectureAvancement = $TempsTotalSong Then
                    _SoundStop($SoundToPlay)
                    _SoundClose($SoundToPlay)
                    Sleep(500)
                    If ControlCommand("", "", $Repeat, "IsChecked", "") = 1 And ControlCommand("", "", $Shuffle, "IsChecked", "") = 0 Then
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, 0)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    ElseIf ControlCommand("", "", $Repeat, "IsChecked", "") = 1 And ControlCommand("", "", $Shuffle, "IsChecked", "") = 1 Then
                        $IndexShuffle = Random(0, $NbrSongsInPlayList, 1)
                        If $IndexShuffle = $CurrentIndexPlay Then $IndexShuffle = $CurrentIndexPlay + 3
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $IndexShuffle))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $IndexShuffle)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $IndexShuffle), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    EndIf
                EndIf
            EndIf
    EndSelect
WEnd

Over to you to modify the rest - and get rid of the "always true" Case statements!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

NEO12,

In my opinion, you need to rethink your main While...WEnd loop and alter a lot of the Case statements. For example, you have 2 examples of :

Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing"

As this will be true whenever you are playing a file, nothing below the first example will ever trigger as the Select will be satisfied at that point.

I would strongly advise that you use only the actual controls as Case statements in the While...WEnd loop and then have If statements to see if the various other parameters are met. At least that way you will see that the controls are being activated and debugging will become easier.

In the following code I have moved (slightly amended as I suggested above) versions of your $MoveForward and $MoveBack Case statements ahead of the "always true" Case and they now function as designed:

#NoTrayIcon
#include <WindowsConstants.au3>
#include <SliderConstants.au3>
#include <ProgressConstants.au3>
#include <ListBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <Sound.au3>
#include <GUIConstants.au3>
#include <GuiListBox.au3>
#include <file.au3>
#include <array.au3>


SplashImageOn("", @ScriptDir & "\splash.bmp", "400", "500", "-1", "-1", 3)
Sleep(3000)
SplashOff()
$Mp3PlayerGui = GUICreate("White Tiger MP3 Player", 420, 600, 272, 170)
GUISetBkColor(0x000000)
$img = GUICtrlCreatePic(@ScriptDir & "\tiger.jpg", 80, 280, 250, 304)
$Open = GUICtrlCreateButton("Ouvrir...", 3, 2, 65, 21, 0)
$Label2 = GUICtrlCreateLabel("Volume :", 8, 32, 61, 17)
GUICtrlSetFont(-1, 8, 800, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Labelvol = GUICtrlCreateLabel("100%", 12, 50, 61, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$Labelvolmin = GUICtrlCreateLabel("0%", 16, 250, 61, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$slider = GUICtrlCreateSlider(8, 65, 49, 180, BitOR($TBS_VERT, $TBS_AUTOTICKS))
GUICtrlSetLimit($slider, 100, 0)
GUICtrlSetData($slider, 50)
GUICtrlSetBkColor(-1, 0x000000)
$Input1 = GUICtrlCreateInput("", 292, 7, 81, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$Label3 = GUICtrlCreateLabel("Durée :", 240, 12, 48, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Play = GUICtrlCreateButton("Lire  >", 128, 39, 57, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PosSong = GUICtrlCreateProgress(121, 67, 238, 14, $PBS_SMOOTH)
GUICtrlSetBkColor(-1, 0x97d1fd)
GUICtrlSetData(-1, 25)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
$Button1 = GUICtrlCreateButton("Pause/Lire", 196, 39, 73, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Button2 = GUICtrlCreateButton("Stop", 279, 39, 57, 21, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$PlayList = GUICtrlCreateList("", 60, 87, 317, 136, BitOR($WS_HSCROLL, $WS_VSCROLL, $WS_BORDER))
GUICtrlSetData(-1, "")
GUICtrlSetColor(-1, 0xFFFFE1)
GUICtrlSetBkColor(-1, 0x808080)
$Label1 = GUICtrlCreateLabel("Playlist :", 60, 65, 42, 17)
$Label4 = GUICtrlCreateLabel("Fichier:", 73, 12, 45, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Input2 = GUICtrlCreateInput("", 125, 7, 110, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$MoveBack = GUICtrlCreateButton("<<", 100, 65, 19, 18)
$MoveForward = GUICtrlCreateButton(">>", 361, 65, 19, 18)
$Button4 = GUICtrlCreateButton("Effacer liste", 60, 223, 150, 27, 0)
$Button5 = GUICtrlCreateButton("Retirer ", 210, 223, 110, 27, 0)
$Shuffle = GUICtrlCreateCheckbox("Shuffle", 324, 223, 52, 12)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetColor(-1, 0xFFFFFF)
$Repeat = GUICtrlCreateCheckbox("Repeat", 324, 237, 53, 12)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)





GUICtrlSetData($PosSong, 0)

Global $old_slider_value = 50
While 1
    $msg = GUIGetMsg()
    $slider_value = GUICtrlRead($slider)

    Select
        Case $msg = $GUI_EVENT_CLOSE
            Global $SoundToPlay
            If IsDeclared($SoundToPlay) Then _SoundClose($SoundToPlay)
            ExitLoop
        Case $msg = $Open
            If _GUICtrlListBox_GetText($PlayList, 0) <> "" Then
                $LastItem = _GUICtrlListBox_GetCount($PlayList)
                $Local = _GUICtrlListBox_GetText($PlayList, $LastItem - 1)
            ElseIf FileExists(@HomeDrive & "") Then
                $Local = @HomeDrive & ""
            ElseIf FileExists(@HomeDrive & "") Then
                $Local = @HomeDrive & ""
            Else
                $Local = @DesktopDir
            EndIf
            $PathToMp3 = FileOpenDialog("Fichier audio à ouvrir...", $Local, "Audio (*.mp3)", 5)
            If StringInStr($PathToMp3, "|") > 0 Then
                $MultiSelect = StringSplit($PathToMp3, "|")
                For $NbrSongs = 2 To UBound($MultiSelect) - 1
                    _GUICtrlListBox_AddString($PlayList, $MultiSelect[1] & "\" & $MultiSelect[$NbrSongs])
                Next
            Else
                If $PathToMp3 <> "" Then
                    _GUICtrlListBox_AddString($PlayList, $PathToMp3)
                EndIf
            EndIf

            If Not IsDeclared("SoundToPlay") Then
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, 0)
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            ElseIf IsDeclared("SoundToPlay") Then
                If _SoundStatus($SoundToPlay) <> "playing" And _SoundStatus($SoundToPlay) <> "paused" Then
                    _SoundClose($SoundToPlay)
                    $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                    GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                    _GUICtrlListBox_SetCurSel($PlayList, 0)
                    Dim $szDrive, $szDir, $szFName, $szExt
                    $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                    GUICtrlSetData($Input2, $NameSong[3])
                    _SoundPlay($SoundToPlay, 0)
                    GUICtrlSetData($PosSong, 0)
                EndIf
            EndIf
        Case $msg = $Play
            If IsDeclared("SoundToPlay") Then
                _SoundStop($SoundToPlay)
                _SoundClose($SoundToPlay)
            EndIf
            If _GUICtrlListBox_GetCurSel($PlayList) <> $LB_ERR Then
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, _GUICtrlListBox_GetCurSel($PlayList)))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, _GUICtrlListBox_GetCurSel($PlayList))
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, _GUICtrlListBox_GetCurSel($PlayList)), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            Else
                $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                _GUICtrlListBox_SetCurSel($PlayList, 0)
                Dim $szDrive, $szDir, $szFName, $szExt
                $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                GUICtrlSetData($Input2, $NameSong[3])
                _SoundPlay($SoundToPlay, 0)
                GUICtrlSetData($PosSong, 0)
            EndIf
        Case $msg = $Button1 And IsDeclared("SoundToPlay")
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                _SoundPause($SoundToPlay)
            ElseIf IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "paused" Then
                _SoundResume($SoundToPlay)
            EndIf
        Case $msg = $Button2 And IsDeclared("SoundToPlay")
            _SoundStop($SoundToPlay)
            _SoundClose($SoundToPlay)
            GUICtrlSetData($PosSong, 0)
        Case $old_slider_value <> $slider_value
            SoundSetWaveVolume(100 - $slider_value)
            $old_slider_value = $slider_value
        Case $msg = $Button4
            _GUICtrlListBox_ResetContent($PlayList)
        Case $msg = $Button5 And _GUICtrlListBox_GetCurSel($PlayList) <> $LB_ERR
            _GUICtrlListBox_DeleteString($PlayList, _GUICtrlListBox_GetCurSel($PlayList))
        Case $msg = $MoveForward   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New version
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                $LectureAvancement = _SoundPos($SoundToPlay, 2) / 1000
                _SoundSeek($SoundToPlay, 0, 0, $LectureAvancement + 5)
                _SoundPlay($SoundToPlay, 0)
            EndIf
        Case $msg = $MoveBack   ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New version
            If IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" Then
                $LectureAvancement = _SoundPos($SoundToPlay, 2) / 1000
                _SoundSeek($SoundToPlay, 0, 0, $LectureAvancement - 1)
                _SoundPlay($SoundToPlay, 0)
            EndIf
        Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" ; <<<<<<<<<<<<<< This is the same
            $TempsTotalSong = _SoundLength($SoundToPlay, 2)
            $LectureAvancement = _SoundPos($SoundToPlay, 2)
            $percent = ($LectureAvancement * 100) / $TempsTotalSong
            GUICtrlSetData($PosSong, $percent)
            If $LectureAvancement = $TempsTotalSong Then
                GUICtrlSetData($PosSong, 0)
            EndIf
        Case IsDeclared("SoundToPlay") And _SoundStatus($SoundToPlay) = "playing" ; <<<<<<<<<<<<<< As this!!!!!!!!!
            $TempsTotalSong = _SoundLength($SoundToPlay, 2)
            $LectureAvancement = _SoundPos($SoundToPlay, 2)
            $CurrentIndexPlay = _GUICtrlListBox_GetCurSel($PlayList)
            $NbrSongsInPlayList = _GUICtrlListBox_GetCount($PlayList) - 1
            If $CurrentIndexPlay <> $NbrSongsInPlayList Then
                If $LectureAvancement = $TempsTotalSong Then
                    _SoundStop($SoundToPlay)
                    _SoundClose($SoundToPlay)
                    Sleep(500)
                    If ControlCommand("", "", $Shuffle, "IsChecked", "") = 0 Then
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $CurrentIndexPlay + 1))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $CurrentIndexPlay + 1)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $CurrentIndexPlay + 1), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    Else
                        $IndexShuffle = Random(0, $NbrSongsInPlayList, 1)
                        If $IndexShuffle = $CurrentIndexPlay Then $IndexShuffle = $CurrentIndexPlay + 3
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $IndexShuffle))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $IndexShuffle)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $IndexShuffle), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    EndIf
                EndIf
            EndIf

            If $CurrentIndexPlay = $NbrSongsInPlayList Then
                If $LectureAvancement = $TempsTotalSong Then
                    _SoundStop($SoundToPlay)
                    _SoundClose($SoundToPlay)
                    Sleep(500)
                    If ControlCommand("", "", $Repeat, "IsChecked", "") = 1 And ControlCommand("", "", $Shuffle, "IsChecked", "") = 0 Then
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, 0))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, 0)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, 0), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    ElseIf ControlCommand("", "", $Repeat, "IsChecked", "") = 1 And ControlCommand("", "", $Shuffle, "IsChecked", "") = 1 Then
                        $IndexShuffle = Random(0, $NbrSongsInPlayList, 1)
                        If $IndexShuffle = $CurrentIndexPlay Then $IndexShuffle = $CurrentIndexPlay + 3
                        $SoundToPlay = _SoundOpen(_GUICtrlListBox_GetText($PlayList, $IndexShuffle))
                        GUICtrlSetData($Input1, _SoundLength($SoundToPlay, 1))
                        _GUICtrlListBox_SetCurSel($PlayList, $IndexShuffle)
                        Dim $szDrive, $szDir, $szFName, $szExt
                        $NameSong = _PathSplit(_GUICtrlListBox_GetText($PlayList, $IndexShuffle), $szDrive, $szDir, $szFName, $szExt)
                        GUICtrlSetData($Input2, $NameSong[3])
                        _SoundPlay($SoundToPlay, 0)
                        GUICtrlSetData($PosSong, 0)
                    EndIf
                EndIf
            EndIf
    EndSelect
WEnd

Over to you to modify the rest - and get rid of the "always true" Case statements!

M23

Thank you. It's working fine. I'm not a great programmer (see join date : 19-June 09). it's since my register to this forum that i'm using autoit.

I didn't thought to pass some seconds but it's also a great idea. just adding 5 seconds forward and 1 back can be usefull. I had something i didn't know about it :D .

Now just adding two button more and it will be ready. [button for next/previous song ( to go to the next/previous song in playlist).] i'm going to work on that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0