Jump to content
Sign in to follow this  
Crome_BAD

SoundPlay Problem

Recommended Posts

Crome_BAD

Hey guys, im having a problem with the SoundPlay function......

Ille post the code...

#include <GUIConstants.au3>

;Optionals
;-------------
Opt("GUICloseOnESC", 0)
;-------------

;Globals
;-------------
Global $Trans = 0
Global $GUIWidth = 300
Global $GUIHeight = 400
Global $DeskWidth = @DesktopWidth
Global $DeskHeight = @DesktopHeight
Global $Style = $WS_POPUP
Global $ExStyle = $WS_EX_CLIENTEDGE + $WS_EX_TOOLWINDOW
;-------------

$MainGUI = GUICreate("", $GUIWidth, $GUIHeight, $DeskWidth + $GUIWidth, 50, $Style, $ExStyle)

$Exit = GUICtrlCreateButton("X", $GUIWidth - 20, 0, 20, 20)
$Minimize = GUICtrlCreateButton("_", $GUIWidth - 40, 0, 20, 20)

$MusicList = GUICtrlCreateList("", 5, 5, 230, 270, $WS_VSCROLL)

$Play = GUICtrlCreateButton("Play", 50, $GUIHeight - 100, 70, 20)
$Stop = GUICtrlCreateButton("Stop", 130, $GUIHeight - 100, 70, 20)

GUICtrlSetState($Stop, $GUI_DISABLE)

;Groups
;-------------
GUICtrlCreateGroup("Player Controls", 45, $GUIHeight - 115, 160, 40, $BS_CENTER)

GUISetState()


PopulateSongs()
WinSetOnTop($MainGUI, "", 1)
Slide($MainGUI)

While 1
    
    $msg = GUIGetMsg()
    
    If $msg = $Exit Then
        Exit
    EndIf
    
    If $msg = $Minimize Then
        Slide($MainGUI)
        _MaxButton()
    EndIf
    
    If $msg = $Play Then
        $Read = GUICtrlRead($MusicList)
        MsgBox(64, "", $Read)
        SoundPlay(@MyDocumentsDir & "\My Music\" & $Read)
        _SoundPlay(@MyDocumentsDir & "\My Music\" & $Read)
    EndIf
    
WEnd

Func _MaxButton()
    
    $MaxGUI = GUICreate("", 100, 18, $DeskWidth - 100, 0, $Style, $ExStyle)
    WinSetTrans($MaxGUI, "", 0)
    
    $Max = GUICtrlCreateButton("Maximize", 0, 0, 100, 20)
    
    GUISetState()
    
    $Trans = 0
    _Trans($MaxGUI)
    
    WinSetOnTop($MaxGUI, "", 1)
    
    While 1
        
        $msg = GUIGetMsg()
        
        If $msg = $Max Then
            $Trans = 255
            _Trans($MaxGUI)
            Slide($MainGUI)
            GUIDelete($MaxGUI)
            ExitLoop
        EndIf
        
    WEnd
    
EndFunc

Func _SoundPlay($Song)
    
    SoundPlay($Song)
    
EndFunc

Func PopulateSongs()
    
    $File = FileFindFirstFile(@MyDocumentsDir & "\My Music\*.mp3")
    
    Do
        
        $Next = FileFindNextFile($File)
        If @error Then
            ExitLoop
        Else
            GUICtrlSetData($MusicList, GUICtrlRead($MusicList) & $Next & @CRLF)
        EndIf
        
    Until 1 = 2
    
EndFunc

Func Slide($WinName)  ;Slides Window In AND Out
   
   WinSetOnTop($WinName, "", 1)
   $Pos = WinGetPos($WinName, "")
   
   Select
   Case $Pos[0] = (@DesktopWidth + 300)
      Do
         WinMove($WinName, "", ($Pos[0] - 1), 100)
         $Pos = WinGetPos($WinName, "")
      Until $Pos[0] = (@DesktopWidth - 300)
      
   Case $Pos[0] = (@DesktopWidth - 300)
      Do
         WinMove($WinName, "", ($Pos[0] + 1), 100)
         $Pos = WinGetPos($WinName, "")
      Until $Pos[0] = (@DesktopWidth + 300)
      
   EndSelect
   
EndFunc

Func _Trans($HWND)
   
   Select
   Case $Trans < 255
      Do
         Sleep(10)
         $Trans = $Trans + 5
         WinSetTrans($HWND, "", $Trans)
      Until $Trans = 255
      
   Case $Trans > 0
      Do
         Sleep(10)
         $Trans = $Trans - 5
         WinSetTrans($HWND, "", $Trans)
      Until $Trans = 0
      
   EndSelect
   
EndFunc

Please help...

Thanks,

Crome

Share this post


Link to post
Share on other sites
datkewlguy

well, what's the problem?

Share this post


Link to post
Share on other sites
layer

whats lthe data on the list? you may have to do a

GUICtrlRead(GUICtrlRead($MusicList))

try that and if it doesnt work, post back :D

nvm, what was i thinking... im trying to find whats wrong. :)

Edited by layer

FootbaG

Share this post


Link to post
Share on other sites
sylvanie

Hello,

Ihave seen , in my case that

$Read = GUICtrlRead($MusicList) returns the title with 2 bad invisible characters at the end, so I have tried that :

If $msg = $Play Then
        $Read = GUICtrlRead($MusicList)
        $Read=StringLeft($Read,StringLen($Read)-2)
         _SoundPlay(@MyDocumentsDir & "\Ma Musique\" & $Read)
EndIf

and it's OK


Share this post


Link to post
Share on other sites
sylvanie

oups ! replace "Ma Musique" (I'm french) by "My Music"

Sorry


Share this post


Link to post
Share on other sites
Crome_BAD

lol omg, thought i posted problem...

When i select my file to play (example:Tada.mp3) it sends it to the _SoundPlay function, but no sound, lol. Its happened before and i let it pass......my OTHER script works fine. I dont wana havta make a seperate program to run a music file....lol...

Thanks,

Crome

EDIT: Fixed, thank you Sylvanie, your solution fixed! Lots of thanks to you

Edited by Crome_BAD

Share this post


Link to post
Share on other sites
layer

damn, i should have noticed that in the music list!!! :)


FootbaG

Share this post


Link to post
Share on other sites
Crome_BAD

Lol this problem has been happening everytime i try to fix it, and it saves some typing:P

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  

×