AutoHotkey Community

It is currently May 27th, 2012, 1:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: November 21st, 2009, 5:41 am 
Offline

Joined: June 12th, 2009, 11:36 pm
Posts: 1173
Location: Indianapolis IN, USA
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

_________________
www.AutoHotkey.net/~Eedis
I love my wife and daughter so much.
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 5:44 am 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
You could write a function that reads the "Duration" parameter of a music file on windows. Then with a little math you can create a 1-100% progress bar with this.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 21st, 2009, 5:45 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
You can use a slider to indicate the current position in the song and allow the user to change it.

I think the BASS Library may be what you want to use for media playback.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Blackholyman, bobbysoon, Google [Bot], iDrug, Ohnitiel, Tipsy3000, Yahoo [Bot] and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group