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 Touchup!

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



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

PostPosted: Sun Aug 31, 2008 6:27 am    Post subject: Music Player Touchup! Reply with quote

[Code Credit Goes To Fry]
Dear users,
I made this small program quite a few months ago and I wish to fix it up now.
Code:
#SingleInstance ignore

FileInstall, SoundFunctions.ahk, SoundFunctions.ahk, 0
SetBatchLines -1
#NoEnv
SetTimer, UpdateTime,100
SetTimer,UpdateProgress,1000
SetTimer,CheckStatus,100
SoundGet, MV
RSound := Round(MV)
playing = 0

; Create the main Edit control and display the window:
Gui, +Resize  ; Make the window resizable.
Gui, Add, Edit, vMainEdit WantTab W300 R10
Gui, Show,, Eclipze Media Player
CurrentFileName =  ; Indicate that there is no current file.
Gui, Add, StatusBar, x176 y70 w290 h30 , Not Playing A File
Gui, Add, Button, x16 y60 w290 h20 gOpenMF, Select A Song
Gui, Add, Button, x200 y80 w80 h20 gStopF, Stop
Gui, Add, Button, x120 y80 w80 h20 gPauseF, Pause
Gui, Add, Button, x40 y80 w80 h20 gResumeF, Resume
Gui, Add, Progress, x16 y20 w290 h30 cBlack vProgress Range1-100 vProgress, 0
Gui, Add, Text, x16 y110 w100 h15 vSongTime, 0:0:0 of 0:0:0
Gui, Add, Text, +Disabled x260 y110 vText_Credits, Happytodd
; Generated using SmartGUI Creator 4.0
Loop, %A_MyDocuments%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeMB, A_LoopFileExt,A_LoopFileFullPath)
LV_ModifyCol()
LV_ModifyCol(2,"Integer")
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

OpenMF:
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Stop(hSound)
    playing = 0
    }
Gui, +OwnDialogs
FileSelectFile, Filetoplay, 3, , Select A Song,
If Filetoplay =
    msgbox,No Song Selected

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:
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:
Sound_Pause(hSound)
return

ResumeF:
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


PlayLV:
LV_GetText(filetoplaylv, A_EventInfo, 4)
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Stop(hSound)
    playing = 0
    }   
hSound := Sound_Open(filetoplaylv)
If Not hSound
   return
playing = 1
Sound_Play(hSound)
Guicontrol,,Progress,0
Guicontrol,% "+Range1-" Sound_Length(hSound) / 1000,Progress
SplitPath, filetoplaylv, filenamelv
SB_SetText("Now Playing " filenamelv)
return

UpdateLV:
Gui, Submit, NoHide
LV_Delete()
Loop, %Directory%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeMB, A_LoopFileExt,A_LoopFileFullPath)
LV_ModifyCol()
LV_ModifyCol(2,"Integer")
return

#Include SoundFunctions.ahk


I was wondering if theres anyway I could make the play button etc have arrows through ascii. notepad doesn't allow ascii so what can I do?
2nd of all I got this code from a friend whos inactive now:
Quote:
MRB_Winamp:
SetKeyDelay, -1, -1
CurrentTrack := MRB_WinampSM()

GuiControlGet, WinampFormat, , varWinampFormat
IfInString, WinampFormat, $title
{
StringReplace, WinampFormat, WinampFormat, $title, %CurrentTrack%
; remove potentially bad characters
StringReplace, WinampFormat, WinampFormat, `r, , All
StringReplace, WinampFormat, WinampFormat, `n, , All
; send it
SendRaw, `r%WinampFormat%`r
Return
}
Else
{
SendRaw, `rWinamp Format does not contain a $title.`r
Return
}
Return

and I was wondering how can I inbed this into my music player without knowing its there. To make it as a little easter egg thing? Thanks guys and looking forward to the replies!
[Code Credit Goes To Fry]
_________________



Last edited by happytodd on Sat Oct 18, 2008 11:14 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Sun Aug 31, 2008 8:35 am    Post subject: Reply with quote

To show characters that can't be displayed by the editor, use the Chr() function with the ASCII number for the character. For example, Chr(234) becomes Ω.
_________________
PlayAHK! Try it out Very Happy
Back to top
View user's profile Send private message AIM Address
happytodd



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

PostPosted: Sun Aug 31, 2008 12:07 pm    Post subject: Reply with quote

When I try and make the ascii into a button it wont work... It'll just show up like this:
Gui, Add, Button, x120 y80 w80 h20 gPauseF, chr(234)
Is this correct?
_________________

Back to top
View user's profile Send private message Visit poster's website
happytodd



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

PostPosted: Fri Oct 17, 2008 4:55 am    Post subject: Reply with quote

bump
_________________

Back to top
View user's profile Send private message Visit poster's website
skwire



Joined: 18 Jan 2006
Posts: 172
Location: Conway, Arkansas

PostPosted: Fri Oct 17, 2008 11:43 am    Post subject: Reply with quote

happytodd wrote:
When I try and make the ascii into a button it wont work... It'll just show up like this:
Gui, Add, Button, x120 y80 w80 h20 gPauseF, chr(234)
Is this correct?


Try this:

Code:
Gui, Add, Button, x120 y80 w80 h20 gPauseF, % chr(234)
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Fri Oct 17, 2008 2:06 pm    Post subject: Reply with quote

This script looks almost identical to my AHK Media Player, It was not made my happytodd but me


My script compared to his , the gui changed but all other code is the same


Please give appropriate credits to me

Code:
#SingleInstance Force
FileInstall, SoundFunctions.ahk, SoundFunctions.ahk, 0
FileInstall, Filter.ini, Filter.ini, 0
SetBatchLines -1
#NoEnv
SetTimer, UpdateSound,5000
SetTimer, UpdateTime,100
SetTimer,UpdateProgress,1000
SetTimer,CheckStatus,100
SoundGet, MV
RSound := Round(MV)
playing = 0
IniRead, Filter, Filter.ini, Config, F
SetTitleMatchMode, 3
Gui, Add, Tab, x-4 y0 w480 h130 , Media|Sound Controls
Gui, Add, Button, x6 y30 w90 h20 gOpenMF, Select Media File
Gui, Add, Button, x116 y30 w50 h20 gStopF, Stop
Gui, Add, Button, x116 y60 w50 h20 gPauseF, Pause
Gui, Tab, Sound Controls
Gui, Add, Slider, x6 y30 w460 h40 vVSlider Range0-100 gVolumeC AltSubmit, %MV%
Gui, Add, Text, x6 y80 w130 h20 vVText, Volume`: %RSound%
Gui, Tab, Media
Gui, Add, Button, x116 y90 w50 h20 gResumeF, Resume
Gui, Tab, Media
Gui, Add, Progress, x176 y30 w290 h30 cBlue vProgress Range1-100 vProgress, 0
Gui, Add, Text, x176 y70 w290 h30 vSongTime, 0:0:0 of 0:0:0
Gui, Add, StatusBar, x176 y70 w290 h30 , Not Playing A File
Gui, Tab, Media
Gui, Add, ListView, x1 y161 w476 h151 gPlayLV vLV, Name|Type|Dir
Gui, Tab, Media
Gui, Add, Button, x0 y130 w169 h31 gAddC, Add File to Collection
Gui, Add, Text, x171 y135 w250 h20 , Click on a file in the collection to play it.
Gui, Tab, Media
Gui, Add, Button, x422 y131 w58 h29 gEC, Empty Collection
; Generated using SmartGUI Creator 4.0
Gui, Show, x357 y382 h347 w488, AHK Media Player
return

GuiClose:
exitapp
return


;Sound Controls
UpdateSound:
Gui, Submit, NoHide
SoundGet, MVU
RSound := Round(MVU)
Guicontrol,,VSlider,%MVU%
GuiControl,,VText,Volume`:%RSound%
return

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

OpenMF:
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Stop(hSound)
    playing = 0
    }
Gui, +OwnDialogs
FileSelectFile, Filetoplay, 3, , Select Media File,Audio %Filter%
If Filetoplay =
    msgbox,No File Selected

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:
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:
Sound_Pause(hSound)
return

ResumeF:
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


PlayLV:
LV_GetText(name, A_EventInfo, 1)
LV_GetText(dir, A_EventInfo, 3)
ToPlay = %dir%\%name%
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Stop(hSound)
    playing = 0
    }
hSound := Sound_Open(ToPlay)
If Not hSound
   return
playing = 1
Sound_Play(hSound)
Guicontrol,,Progress,0
Guicontrol,% "+Range1-" Sound_Length(hSound) / 1000,Progress
SB_SetText("Now Playing " name)
return

UpdateLV:
Gui, Submit, NoHide
LV_Delete()
Loop, %Directory%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeMB, A_LoopFileExt,A_LoopFileFullPath)
LV_ModifyCol()
LV_ModifyCol(2,"Integer")
return

AddC:
If hSound =
    gosub CAM
Else
{
CheckSong := Sound_Status(hSound)
If CheckSong = playing
    {
    Sound_Pause(hSound)
    playing = 0
    gosub CAM
    }
}
return
CAM:
Critical
Gui, +OwnDialogs
Thread,NoTimers
Sleep,200 ; Ensure No timers start
FileSelectFile,FilesToAdd,M3,,Select Media File,Audio %Filter%
Thread,Notimers,False
If (!FilesToAdd){
  Return
}
Loop, parse, FilestoAdd, `n
{
    if (a_index != 1){
      SplitPath,A_loopField,,,FileExt
      LV_Add("",a_loopfield,FileExt,dir)
    }
    Else {
      Dir:=a_loopField
    }
 
}
If hSound =
    return
LV_ModifyCol()
Sound_Resume(hSound)

return


EC:
LV_Delete()
return




#Include SoundFunctions.ahk
^h::
IfWinExist, AHK Media Player
WinHide, AHK Media Player
else
WinShow, AHK Media Player
return

_________________
check out my site
www.eliteknifesquad.com
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 970
Location: London, UK

PostPosted: Fri Oct 17, 2008 2:42 pm    Post subject: Reply with quote

I thought so Fry, I remembered the code because I remember assisting you with it, and I checked it with the version I had, and it was almost exactly the same.

That reminds me, I must finish of my version.
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Fry



Joined: 01 Nov 2007
Posts: 689

PostPosted: Fri Oct 17, 2008 2:43 pm    Post subject: Reply with quote

Ok just please give me credits
_________________
check out my site
www.eliteknifesquad.com
Back to top
View user's profile Send private message
happytodd



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

PostPosted: Sat Oct 18, 2008 11:13 am    Post subject: Reply with quote

Thats right Fry, I remember helping you with it and you were talking to me in mail once upon a time. I forgot your name and yeah... Thanks for sharing light and I shall give you credit Very Happy
_________________

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   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