Sign in to follow this  
Followers 0
Zisly

Problems with playlist

5 posts in this topic

#1 ·  Posted (edited)

Well, I cant get my playlist to work, i have been trying for some time now changing alot of things and so on, but it just wont work.

So I hope someone could be nice and help me =)

Here is the code>

#NoTrayIcon
#include <Sound.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ExtProp.au3>

Global $Slider_volume, $Casella1, $Casella2, $Durata_ms, $Tempo_ms, $Percentuale

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$Z = GUICreate("Z Player", 547, 226, 193, 125)
GUISetBkColor(0x000000)
$open = GUICtrlCreateButton("(Not allowed)", 136, 96, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\Open.bmp", 0)
$pause = GUICtrlCreateButton("(Not allowed)", 72, 64, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\Pause.bmp", 0)
$stop = GUICtrlCreateButton("(Not allowed)", 200, 64, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\Stop.bmp", 0)
$play = GUICtrlCreateButton("(Not allowed)", 136, 32, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\play.bmp", 0)
$list = GUICtrlCreateListView("                   Music                     ", 336, 32, 161, 188)
$Groupplaylist = GUICtrlCreateGroup("Playlist", 336, 8, 161, 25, $BS_CENTER)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Slider1 = GUICtrlCreateSlider(72, 184, 246, 32, BitOR($TBS_NOTICKS,$TBS_FIXEDLENGTH))
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\vol.bmp", 8, 184, 65, 32, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


$Percorso = 0
GUICtrlSetData ($Slider1, 100)
Dim $DoubleClicked = False, $playlist, $adddir

AdlibEnable("_MyAdlib", 500)

While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
_SoundClose ("alias_suono")
Exit
Case $nMsg = $open
$Percorso = (FileOpenDialog("Select which files to play", @ScriptDir, "(*.mp3;*.wav;*.wma)") )
GUICtrlSetData ($list, $Percorso)
If $Casella1 = 1 Then
While $Slider_volume > 0
$Slider_volume = $Slider_volume - 1
SoundSetWaveVolume ($Slider_volume)
Sleep (30)
WEnd
EndIf
_SoundClose ("alias_suono")
_SoundOpen ($Percorso, "alias_suono")
Case $nMsg = $Play
adddir()
_SoundPlay ("alias_suono")
Case $nMsg = $pause
_SoundPause ("alias_suono")
Case $nMsg = $Stop
If $Casella1 = 1 Then
While $Slider_volume > 0
$Slider_volume = $Slider_volume - 1
SoundSetWaveVolume ($Slider_volume)
Sleep (30)
WEnd
EndIf
_SoundStop ("alias_suono")
EndSelect

If $DoubleClicked Then
DoubleClickFunc()
$DoubleClicked = False
EndIf
WEnd

Func _MyAdlib()
$Slider_volume = GUICtrlRead ($Slider1)
SoundSetWaveVolume ($Slider_volume)
EndFunc


Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam)
If @error Then Return 0
$code = DllStructGetData($tagNMHDR, 3)
If $wParam = $list And $code = -3 Then $DoubleClicked = True
Return $GUI_RUNDEFMSG
EndFunc;==>WM_NOTIFY

Func DoubleClickFunc()
ConsoleWrite("dc" & @CRLF)
If _SoundStatus("alias_suono") = "playing" Then
_SoundStop("alias_suono")
_SoundClose("alias_suono")
EndIf
$dbclick1 = GUICtrlRead(GUICtrlRead($list))
ConsoleWrite($dbclick1 & @CRLF)
$dbclick2 = StringTrimRight($dbclick1, 1)
ConsoleWrite($dbclick2 & @CRLF)
$dbclick3 = StringSplit($dbclick2, "|")
ConsoleWrite($dbclick3[4] & @CRLF)
_SoundOpen($dbclick3[4],"alias_suono")
_SoundPlay("alias_suono")
EndFunc;==>DoubleClickFunc

Func adddir()
$dir = FileSelectFolder("Select folder",@HomeDrive)
$array = _FileListToArray($dir,"*.mp3")
If IsArray($array) Then
For $i = 1 To $array[0]
TrayTip("Adding files ...","File " & $i & " of " & $array[0],1)
$music = $dir & "\" & $array[$i]


Next
Else
MsgBox(32,"Error","Please select a folder")
EndIf
EndFunc

Thanks in advance!

Btw< I know I have putted the function on the play button , but thats just for testing.

Edited by Zisly

Share this post


Link to post
Share on other sites



You should add recusive file to search the file you want...

this is example that i take from limiter player...

;#NoTrayIcon
#include <Sound.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ExtProp.au3>


Global $Slider_volume, $Casella1, $Casella2, $Durata_ms, $Tempo_ms, $Percentuale

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

$Z = GUICreate("Z Player", 547, 226, 193, 125)
GUISetBkColor(0x000000)
$open = GUICtrlCreateButton("(Not allowed)", 136, 96, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\Open.bmp", 0)
$pause = GUICtrlCreateButton("(Not allowed)", 72, 64, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\Pause.bmp", 0)
$stop = GUICtrlCreateButton("(Not allowed)", 200, 64, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\Stop.bmp", 0)
$play = GUICtrlCreateButton("(Not allowed)", 136, 32, 65, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\play.bmp", 0)
$list = GUICtrlCreateListView("                   Music                     ", 336, 32, 161, 188)
$Groupplaylist = GUICtrlCreateGroup("Playlist", 336, 8, 161, 25, $BS_CENTER)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Slider1 = GUICtrlCreateSlider(72, 184, 246, 32, BitOR($TBS_NOTICKS,$TBS_FIXEDLENGTH))
$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\lol\Desktop\Z_Player_1.0.2\Z Player 1.0.2\Data\vol.bmp", 8, 184, 65, 32, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


$Percorso = 0
GUICtrlSetData ($Slider1, 100)
Dim $DoubleClicked = False, $playlist, $adddir

AdlibEnable("_MyAdlib", 500)

While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
_SoundClose ("alias_suono")
Exit
Case $nMsg = $open
$Percorso = (FileOpenDialog("Select which files to play", @ScriptDir, "(*.mp3;*.wav;*.wma)") )
GUICtrlSetData ($list, $Percorso)
If $Casella1 = 1 Then
While $Slider_volume > 0
$Slider_volume = $Slider_volume - 1
SoundSetWaveVolume ($Slider_volume)
Sleep (30)
WEnd
EndIf
_SoundClose ("alias_suono")
_SoundOpen ($Percorso, "alias_suono")
Case $nMsg = $Play
adddir()
_SoundPlay ("alias_suono")
Case $nMsg = $pause
_SoundPause ("alias_suono")
Case $nMsg = $Stop
If $Casella1 = 1 Then
While $Slider_volume > 0
$Slider_volume = $Slider_volume - 1
SoundSetWaveVolume ($Slider_volume)
Sleep (30)
WEnd
EndIf
_SoundStop ("alias_suono")
EndSelect

If $DoubleClicked Then
DoubleClickFunc()
$DoubleClicked = False
EndIf
WEnd

Func _MyAdlib()
$Slider_volume = GUICtrlRead ($Slider1)
SoundSetWaveVolume ($Slider_volume)
EndFunc


Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam)
If @error Then Return 0
$code = DllStructGetData($tagNMHDR, 3)
If $wParam = $list And $code = -3 Then $DoubleClicked = True
Return $GUI_RUNDEFMSG
EndFunc;==>WM_NOTIFY

Func DoubleClickFunc()
ConsoleWrite("dc" & @CRLF)
If _SoundStatus("alias_suono") = "playing" Then
_SoundStop("alias_suono")
_SoundClose("alias_suono")
EndIf
$dbclick1 = GUICtrlRead(GUICtrlRead($list))
ConsoleWrite($dbclick1 & @CRLF)
$dbclick2 = StringTrimRight($dbclick1, 1)
ConsoleWrite($dbclick2 & @CRLF)
$dbclick3 = StringSplit($dbclick2, "|")
ConsoleWrite($dbclick3[4] & @CRLF)
_SoundOpen($dbclick3[4],"alias_suono")
_SoundPlay("alias_suono")
EndFunc;==>DoubleClickFunc

Func adddir()
$dir = FileSelectFolder("Select folder",@HomeDrive)
$filesArray = RecursiveFileSearch($dir, "(?i)\.(mp3|wav)")
;$array = _FileListToArray($dir,"*.mp3")
If IsArray($filesArray) Then
For $i = 1 To $filesArray[0]
    TrayTip("Adding files ...","File " & $i & " of " & $filesArray[0],1)
    $path = $filesArray[$i]
    $artist1 = _GetExtProperty($path, 16) 
    GUICtrlCreateListViewItem($artist1 , $list)
    
;$music = $dir & "\" & $array[$i]


Next
GUICtrlSetState($list, $GUI_SHOW)
Else
MsgBox(32,"Error","Please select a folder")
EndIf
EndFunc

#cs ----------------------------------------------------------------------------
     AutoIt Version: 3.2.10.0
     Author: WeaponX
     Updated: 2/21/08
     Script Function: Recursive file search
     
     2/21/08 - Added pattern for folder matching, flag for return type
     1/24/08 - Recursion is now optional

Parameters:

RFSstartdir: Path to starting folder

RFSFilepattern: RegEx pattern to match
     "\.(mp3)" - Find all mp3 files - case sensitive (by default)
     "(?i)\.(mp3)" - Find all mp3 files - case insensitive
     "(?-i)\.(mp3|txt)" - Find all mp3 and txt files - case sensitive

RFSFolderpattern:
     "(Music|Movies)" - Only match folders named Music or Movies - case sensitive (by default)
     "(?i)(Music|Movies)" - Only match folders named Music or Movies - case insensitive
     "(?!(Music|Movies)\b)\b.+" - Match folders NOT named Music or Movies - case sensitive (by default)

RFSFlag: Specifies what is returned in the array
     0 - Files and folders
     1 - Files only
     2 - Folders only

RFSrecurse: TRUE = Recursive, FALSE = Non-recursive

RFSdepth: Internal use only

#ce ----------------------------------------------------------------------------
Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = true, $RFSdepth = 0)
     
  ;Ensure starting folder has a trailing slash
     If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\"

     If $RFSdepth = 0 Then
      ;Get count of all files in subfolders for initial array definition
         $RFSfilecount = DirGetSize($RFSstartDir, 1)
         
      ;File count + folder count (will be resized when the function returns)
         Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1]
     EndIf
     
     $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*")
     If @error Then Return

  ;Search through all files and folders in directory
     While 1
         $RFSnext = FileFindNextFile($RFSsearch)
         If @error Then ExitLoop
         
      ;If folder and recurse flag is set and regex matches
         If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then
             
             If $RFSrecurse AND StringRegExp($RFSnext, $RFSFolderpattern, 0) Then
                 RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1)
                 If $RFSFlag <> 1 Then
                  ;Append folder name to array
                     $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext
                     $RFSarray[0] += 1
                 EndIf
             EndIf
         ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) AND $RFSFlag <> 2 Then
          ;Append file name to array
             $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext
             $RFSarray[0] += 1
         EndIf
     WEnd
     FileClose($RFSsearch)

     If $RFSdepth = 0 Then
         Redim $RFSarray[$RFSarray[0] + 1]
         Return $RFSarray
     EndIf
EndFunc;==>RecursiveFileSearch

Share this post


Link to post
Share on other sites

Thanks, but now I'm getting this:

Posted Image

Posted Image

muttley

Thanks in advance.

Share this post


Link to post
Share on other sites

Bump...

Still need help

Share this post


Link to post
Share on other sites

Bump...

Still need help

Better you try to look this....

i also use this site as my reference..

L|M|TER


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