Eedis
Joined: 12 Jun 2009 Posts: 389
|
Posted: Sat Nov 21, 2009 4:41 am Post subject: Need help with a self-made Media Player. |
|
|
I've had an idea for a little Media Player type thing. I haven't really coded anything yet, haven't gotten around time but I wanted to post this question before I forgot about it.
Well I'm going to use listview to get all the music and what not and then have a seperate listview for the playlist and just use SoundPlay to play them in order. I have an idea for all the main features of most media players, Pause/Play, Next, Previous, Stop and that stuff.
The problem is the little bar that indicates how far the song is in. I have an idea, but unsure how to go about doing it. I wanted to somehow read the duration of the song, then use that with a little progress bar.
That sounds remotely easy, but it's the fact of being able to drag the bar to get it to go to the part of the song it's supposed to. XD That sounds a bit complicated. I'm sure I'd have to use DllCalls and I've never used them so I'm going to use this script as an excuse to start learning DllCalls.
I've mentioned before, I write different scripts to learn different aspects of AHK to enhance my code-ability (for lack of better word) and I want to use this to learn DllCalls. So could anyone please point me in the right direction? I'm sure I will have plenty of other questions in the future when I start writing it.
This is the code I have so far without the whole playlist function.
| Code: | IfNotExist, %A_ProgramFiles%\Pleyer\Pleyerpath.ini
iniwrite, Path, %A_ProgramFiles%\Pleyer\Pleyerpath.ini, Settings, Path
Menu, MyMenu, Add, Play, Play
Menu, MyMenu, Add
Menu, MyMenu, Add, Up, Up
Menu, MyMenu, Add
Menu, MyMenu, Add, Exit, Exit
iniread, path, %A_ProgramFiles%\Pleyer\Pleyerpath.ini, Settings, Path
Gui, Color, FF8040
Gui, Font, S44 CGreen Bold, Papyrus
Gui, Add, Text, x86 y0 w170 h90 +BackgroundTrans, Pleyer
Gui, Font, S12 CGreen Bold, Arial
Gui, Add, Text, x-108 y70 w560 h30 +BackgroundTrans, ___________________________________________________
Gui, Font, S12 CGreen, Arial
Gui, Add, Edit, x6 y100 w220 h20 veditpath, %path%
Gui, Add, Button, x236 y100 w90 h20 , Browse
Gui, Add, ListView, x6 y130 w330 h440 gPleyer, Name|Path
Gui, Show, w345 h582, Pleyer
a:
Loop, %path%\*.*, 2
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
Loop, %path%\*.mp3
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
Loop, %path%\*.wma
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
Loop, %path%\*.wav
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
LV_ModifyCol(1, 200)
LV_ModifyCol(2)
Gui, Show
return
buttonbrowse:
{
LV_Delete()
FileSelectFolder, path
if errorlevel
{
iniread, path, %A_ProgramFiles%\Pleyer\Pleyerpath.ini, Settings, Path
goto, a
}
GuiControl,, Edit1, %path%
LV_Delete()
goto, a
}
Return
Pleyer:
if A_GuiEvent = DoubleClick
{
gui, submit, nohide
LV_GetText(RowText, A_EventInfo, 2)
IfInString, rowtext, .mp3
{
run, %rowtext%
Return
}
IfInString, rowtext, .wav
{
run, %rowtext%
Return
}
IfInString, rowtext, .wma
{
run, %rowtext%
Return
}
LV_GetText(RowText, A_EventInfo, 2)
LV_Delete()
gui, submit, NoHide
path:=editpath
GuiControl,, Edit1, %RowText%
Loop, %RowText%\*.*, 2
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
Loop, %RowText%\*.mp3
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
Loop, %RowText%\*.wma
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
Loop, %RowText%\*.wav
LV_Add("", A_LoopFileName, A_LoopFileLongPath)
LV_ModifyCol(1, 200)
LV_ModifyCol(2)
Gui, Show
}
return
GuiContextMenu:
if A_GuiControl <> Pleyer
Menu, MyMenu, Show, %A_GuiX%, %A_GuiY%
return
up:
gui, submit, nohide
stringsplit, splitpath, editpath, \
Loop, %SplitPath0%
stringnum:=A_index
StringLen, length, splitpath%stringnum%
length+=1
StringTrimRight, path, editpath, %length%
lv_delete()
GuiControl,, Edit1, %path%
goto, a
Return
Play:
RowNumber = 0
Loop
{
RowNumber := LV_GetNext(RowNumber)
if not RowNumber
break
LV_GetText(Text, RowNumber)
gui, submit, nohide
run, %editpath%\%text%
Return
}
Return
^m::
{
if (var = 0)
{
gui, show
var = 1
}
else
{
gui, hide
var = 0
}
}
Return
Exit:
GuiClose:
gui, submit, NoHide
iniwrite, %editpath%, %A_ProgramFiles%\Pleyer\Pleyerpath.ini, Settings, Path
ExitApp |
_________________ Pylons Are Trapped Balls.
http://www.autohotkey.net/~Eedis/
 |
|