AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Music Player - Song Status

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
happytodd



Joined: 12 Nov 2007
Posts: 142
Location: South Australia

PostPosted: Sun May 17, 2009 7:08 am    Post subject: Music Player - Song Status Reply with quote

Dear users for a few months now been fixing up my music player here and there. At the moment I have a statusbar that shows the current song playing.
Code:
#notrayicon
#SingleInstance force

FileInstall, bin\SoundFunctions.ahk, bin\SoundFunctions.ahk, 0
FileInstall, bin\Filter.ini, bin\Filter.ini, 0
SetBatchLines -1
#NoEnv
SetTimer, UpdateTime,100
SetTimer,UpdateProgress,1000
SetTimer,CheckStatus,100
SoundGet, MV
RSound := Round(MV)
playing = 0
IniRead, Filter, bin\Filter.ini, Config, F

FADE       := 524288
SHOW       := 131072
HIDE       := 65536

FADE_SHOW  := FADE+SHOW
FADE_HIDE  := FADE+HIDE

;Converting the above to Hexdecimal value

SetFormat, Integer, Hex
FADE_SHOW+=0 ; Converts to 0xa0000
FADE_HIDE+=0 ; Converts to 0x90000
SetFormat, Integer, d

Duration = 1000 ; Duration of Animation in milliseconds

Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist() ; Handle to the GUI

; Create the main Edit control and display the window:
Gui, Add, Edit, vMainEdit WantTab W300 R10
Gui, -Caption +ToolWindow +0x400000
Gui, Add, Text,x259 y5 w12 h12  Border Center GuiMove,
Gui, Show, Eclipze Music Player
AnimateWindow(GUI_ID, Duration, FADE_SHOW)
CurrentFileName =  ; Indicate that there is no current file.
Gui, Add, StatusBar, x162 y70 w290 h30 , Not Playing A File
Gui, Add, Progress,  x2 y19 w280 h30 cAqua Backgroundblack vProgress Range1-100 vProgress, 0
gui,add,picture, x2 y19, Skins\Bar2.jpg
gui,add,picture, x2 y48, Skins\Bar2.jpg
gui,add,picture, x2 y19, Skins\Bar3.jpg
gui,add,picture, x281 y19, Skins\Bar3.jpg
Gui, Add, Text, x111 y65 w100 h15 CAqua vSongTime, 0:0:0 of 0:0:0
Gui, Add, Text, cAqua x1 y6 vText_Heading, // Eclipze Music Player //
Gui, Add, Text, cAqua x230 y65 gCreditsF vText_Credits, Happytodd
gui,add,picture, x2 y62 gOpenMF, Skins\Select_song.jpg
gui,add,picture, x2 y88 gResumeF, Skins\Resume_song.jpg
gui,add,picture, x95 y88 gPauseF, Skins\Pause_song.jpg
gui,add,picture, x188 y88 gStopF, Skins\Stop_song.jpg
gui,add,picture, x247 y5 gMinimizeF, Skins\Minimize.jpg
gui,add,picture, x271 y5 gExitF, Skins\Close.jpg
gui,add,picture, x97 y62 gIncreaseF, Skins\Increase.jpg
gui,add,picture, x97 y74 gDecreaseF, Skins\Minimize.jpg
gui,add,picture, x259 y5, Skins\Move.jpg
gui,add,picture, x283 y5, Skins\Bar1.jpg
gui,add,picture, x0 y5, Skins\Bar1.jpg
gui,add,picture, x0 y5, Skins\Bar2.jpg
gui,add,picture, x1 y116, Skins\Bar2.jpg
gui,color,000000
WinSet, Region, 3-8   287-8    287-142   3-142    , Eclipze Music Player
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiSize:
if ErrorLevel = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the Edit control to match.
GuiControl, Move, MainEdit, W%NewWidth% H%NewHeight%
return

VolumeC:
Gui, Submit, NoHide
SoundSet,%VSlider%,master
GuiControl,, VText,Volume`:%VSlider%
Return
;Sound Controls

ExitF:
SoundPlay, bin\Mp3\exit.wav
AnimateWindow(GUI_ID, Duration, FADE_HIDE)
CheckSong := Sound_Status(hSound)
If CheckSong = playing
Sound_Stop(hSound)
sleep 1
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
exitapp
Return

AnimateWindow(hWnd,Duration,Flag) {
Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)
}

IncreaseF:
#IfWinActive Eclipze Music Player
WheelUp::
Send {Volume_Up}
return

DecreaseF:
#IfWinActive Eclipze Music Player
WheelDown::
Send {Volume_Down}
return

MinimizeF:
winMinimize
winRestore
return
;|||||||||||||||||||||||||Gui, Minimize /winrestore

OpenMF:
SoundPlay, bin\Mp3\sound11026.wav
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Stop(hSound)
    playing = 0
    }
Gui, +OwnDialogs
FileSelectFile, Filetoplay, 3, , Select A Song,Audio %Filter%
filename=
sleep 100
SplitPath, Filetoplay, filename
sleep 100

hSound := Sound_Open(Filetoplay)
If Not hSound
   return
playing = 1
Sound_Play(hSound)
Guicontrol,,Progress,0
Guicontrol,% "+Range1-" Sound_Length(hSound) / 1000,Progress
SplitPath, Filetoplay, filename
SB_SetText("Now Playing "filename)
return

StopF:
SoundPlay, bin\Mp3\sound11027.wav
Sound_Stop(hSound)
playing = 0
Guicontrol,,Progress,0
GuiControl,,SongTime,0:0:0 of 0:0:0
SB_SetText("Not Playing A File")
return

PauseF:
SoundPlay, bin\Mp3\sound11027.wav
Sound_Pause(hSound)
return

ResumeF:
SoundPlay, bin\Mp3\sound11027.wav
Sound_Resume(hSound)
return

UpdateTime:
If playing = 0
      return
If(Sound_Pos(hSound) = Sound_Length(hSound))
      return
GuiControl,,SongTime,% Tohhmmss(Sound_Pos(hSound)) .  " of "  . Tohhmmss(Sound_Length(hSound))
return

UpdateProgress:
If playing = 0
      return
If(Sound_Pos(hSound) = Sound_Length(hSound))
      return
Guicontrol,,Progress,% (Sound_Pos(hSound) / 1000)
Return

CheckStatus:
Status := Sound_Status(hSound)
If Status = stopped
    {
    sleep 1500
    Guicontrol,,Progress,0
    Guicontrol,,SongTime,0:0:0 of 0:0:0
    SB_SetText("Not Playing A File")
    }
return

CreditsF:
^H::
  MsgBox, 32, About %GUI_TITLE% %GUI_VERSION% %GUI_BUILDDATE%,
  ( LTrim,
    Eclipze Music Player was designed for educational purposes only.
   
    It started back in early November 2007. I started
    studying a program called AutoHotKey from there I have
    designed this short program for everyone to try out.
    If anyone has any complaints of suggestions please
    email me.
   
    Eclipze Music Player works on Windows 2000/XP/NT and
    above only.
    Author:
    ` ` Happytodd <Happytodd@senet.com.au>

    Special Thanks:
    ` ` Paulo-nli, engunneer, lexikos, Micahs, garry,
    ` ` Superfraggle, ~dieom, Laszlo, senbei_luffy,
    ` ` ChronstixZ, SKAN, gregg, evan, DataLife,
    ` ` Jedimoony, and tonne.
  )
Return

#Include bin\SoundFunctions.ahk


However I wish to get rid of the statusbar and change it to text/edit. This way it will look more professional than the statusbar. In my oppinion anyway.
Heres one with the text/edit
Code:
#notrayicon
#SingleInstance force

FileInstall, bin\SoundFunctions.ahk, bin\SoundFunctions.ahk, 0
FileInstall, bin\Filter.ini, bin\Filter.ini, 0
SetBatchLines -1
#NoEnv
SetTimer, UpdateTime,100
SetTimer,UpdateProgress,1000
SetTimer,CheckStatus,100
SoundGet, MV
RSound := Round(MV)
playing = 0
IniRead, Filter, bin\Filter.ini, Config, F

FADE       := 524288
SHOW       := 131072
HIDE       := 65536

FADE_SHOW  := FADE+SHOW
FADE_HIDE  := FADE+HIDE

;Converting the above to Hexdecimal value

SetFormat, Integer, Hex
FADE_SHOW+=0 ; Converts to 0xa0000
FADE_HIDE+=0 ; Converts to 0x90000
SetFormat, Integer, d

Duration = 1000 ; Duration of Animation in milliseconds

Gui, Margin, 0,0
Gui +LastFound
GUI_ID:=WinExist() ; Handle to the GUI

; Create the main Edit control and display the window:
Gui, Add, Text, CAqua v111 x2 y50 w330 h20 , Status:
Gui, Add, Edit, vMainEdit WantTab W300 R10
Gui, -Caption +ToolWindow +0x400000 +AlwaysOnTop
Gui, Add, Text,x259 y5 w12 h12  Border Center GuiMove,
Gui, Show, Eclipze Music Player
AnimateWindow(GUI_ID, Duration, FADE_SHOW)
CurrentFileName =  ; Indicate that there is no current file.
Gui, Add, Text, cAqua x1 y6 vText_Heading, // Eclipze Music Player //
Gui, Add, Progress,  x2 y19 w280 h30 cAqua Backgroundblack vProgress Range1-100 vProgress, 0
gui,add,picture, x2 y19, Skins\Bar2.jpg
gui,add,picture, x2 y48, Skins\Bar2.jpg
gui,add,picture, x2 y19, Skins\Bar3.jpg
gui,add,picture, x281 y19, Skins\Bar3.jpg
Gui, Add, Text, x111 y65 w100 h15 CAqua vSongTime, 0:0:0 of 0:0:0
Gui, Add, Text, cAqua x230 y65 gCreditsF vText_Credits, Happytodd
gui,add,picture, x2 y62 gOpenMF, Skins\Select_song.jpg
gui,add,picture, x2 y88 gResumeF, Skins\Resume_song.jpg
gui,add,picture, x95 y88 gPauseF, Skins\Pause_song.jpg
gui,add,picture, x188 y88 gStopF, Skins\Stop_song.jpg
gui,add,picture, x247 y5 gMinimizeF, Skins\Minimize.jpg
gui,add,picture, x271 y5 gExitF, Skins\Close.jpg
gui,add,picture, x97 y62 gIncreaseF, Skins\Increase.jpg
gui,add,picture, x97 y74 gDecreaseF, Skins\Minimize.jpg
gui,add,picture, x259 y5, Skins\Move.jpg
gui,add,picture, x283 y5, Skins\Bar1.jpg
gui,add,picture, x0 y5, Skins\Bar1.jpg
gui,add,picture, x0 y5, Skins\Bar2.jpg
gui,add,picture, x1 y116, Skins\Bar2.jpg
gui,color,000000
WinSet, Region, 3-8   287-8    287-142   3-142    , Eclipze Music Player
Return

uiMove:
PostMessage, 0xA1, 2,,, A
Return

GuiSize:
if ErrorLevel = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the Edit control to match.
GuiControl, Move, MainEdit, W%NewWidth% H%NewHeight%
return

VolumeC:
Gui, Submit, NoHide
SoundSet,%VSlider%,master
GuiControl,, VText,Volume`:%VSlider%
Return
;Sound Controls

ExitF:
SoundPlay, bin\Mp3\exit.wav
AnimateWindow(GUI_ID, Duration, FADE_HIDE)
CheckSong := Sound_Status(hSound)
If CheckSong = playing
Sound_Stop(hSound)
sleep 1
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
Send {Volume_Up}
exitapp
Return

AnimateWindow(hWnd,Duration,Flag) {
Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)
}

IncreaseF:
#IfWinActive Eclipze Music Player
WheelUp::
Send {Volume_Up}
return

DecreaseF:
#IfWinActive Eclipze Music Player
WheelDown::
Send {Volume_Down}
return

MinimizeF:
winMinimize
winRestore
return
;|||||||||||||||||||||||||Gui, Minimize /winrestore

OpenMF:
SoundPlay, bin\Mp3\sound11026.wav
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Stop(hSound)
    playing = 0
    }
Gui, +OwnDialogs
FileSelectFile, Filetoplay, 3, , Select A Song,Audio %Filter%
filename=
sleep 100
SplitPath, Filetoplay, filename
sleep 100

hSound := Sound_Open(Filetoplay)
If Not hSound
   return
playing = 1
Sound_Play(hSound)
Guicontrol,,Progress,0
Guicontrol,% "+Range1-" Sound_Length(hSound) / 1000,Progress
ControlSetText, %111%, Status: Successful, // Eclipze Music Player //
SplitPath, Filetoplay, filename
ControlSetText, %111%, Status: Now Playing A File, // Eclipze Music Player //
return

StopF:
SoundPlay, bin\Mp3\sound11027.wav
Sound_Stop(hSound)
playing = 0
Guicontrol,,Progress,0
GuiControl,,SongTime,0:0:0 of 0:0:0
ControlSetText, %111%, Status: Not Playing A File, // Eclipze Music Player //
return

PauseF:
SoundPlay, bin\Mp3\sound11027.wav
Sound_Pause(hSound)
return

ResumeF:
SoundPlay, bin\Mp3\sound11027.wav
Sound_Resume(hSound)
return

UpdateTime:
If playing = 0
      return
If(Sound_Pos(hSound) = Sound_Length(hSound))
      return
GuiControl,,SongTime,% Tohhmmss(Sound_Pos(hSound)) .  " of "  . Tohhmmss(Sound_Length(hSound))
return

UpdateProgress:
If playing = 0
      return
If(Sound_Pos(hSound) = Sound_Length(hSound))
      return
Guicontrol,,Progress,% (Sound_Pos(hSound) / 1000)
Return

CheckStatus:
Status := Sound_Status(hSound)
If Status = stopped
    {
    sleep 1500
    Guicontrol,,Progress,0
    Guicontrol,,SongTime,0:0:0 of 0:0:0
ControlSetText, %111%, Status: Not Playing A File, // Eclipze Music Player //
    }
return

CreditsF:
^H::
  MsgBox, 32, About %GUI_TITLE% %GUI_VERSION% %GUI_BUILDDATE%,
  ( LTrim,
    Eclipze Music Player was designed for educational purposes only.
   
    It started back in early November 2007. I started
    studying a program called AutoHotKey from there I have
    designed this short program for everyone to try out.
    If anyone has any complaints of suggestions please
    email me.
   
    Eclipze Music Player works on Windows 2000/XP/NT and
    above only.
    Author:
    ` ` Happytodd <Happytodd@senet.com.au>

    Special Thanks:
    ` ` Paulo-nli, engunneer, lexikos, Micahs, garry,
    ` ` Superfraggle, ~dieom, Laszlo, senbei_luffy,
    ` ` ChronstixZ, SKAN, gregg, evan, DataLife,
    ` ` Jedimoony, and tonne.
  )
Return

#Include bin\SoundFunctions.ahk


But I'm unable to get the text/edit to work... and I have no idea to fix it. Can someone point me in the right direction please. The code is under OpenMF. Thanks guys!
_________________

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group