happytodd
Joined: 12 Nov 2007 Posts: 83 Location: South Australia
|
Posted: Mon May 26, 2008 12:40 pm Post subject: media Player with library. |
|
|
Dear users,
I am currently making a media player but I am having some problems with it.
heres the code:
| Code: | #SingleInstance ignore
FileInstall, SoundFunctions.ahk, SoundFunctions.ahk, 0
FileInstall, Filter.ini, Filter.ini, 0
SetBatchLines -1
#NoEnv
SetTimer, UpdateTime,100
SetTimer,UpdateProgress,1000
SetTimer,CheckStatus,100
SoundGet, MV
RSound := Round(MV)
playing = 0
IniRead, Filter, Filter.ini, Config, F
; 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, Tab, x-4 y0 w480 h130 , Media|Library
Gui, Tab, Library
Gui, Add, ListView, x16 y30 w290 h80 gPlayLV vLV, Media File Name
Gui, Add, Button, x16 y112 w80 h20 gAddC, Add File
Gui, Tab, Media
Gui, Add, StatusBar, x176 y70 w290 h30 , Not Playing A File
Gui, Add, Button, x16 y62 w290 h20 gOpenMF, Select A Song
Gui, Add, Button, x200 y82 w80 h20 gStopF, Stop
Gui, Add, Button, x120 y82 w80 h20 gPauseF, Pause
Gui, Add, Button, x40 y82 w80 h20 gResumeF, Resume
Gui, Add, Progress, x16 y30 w290 h30 cBlack vProgress Range1-100 vProgress, 0
Gui, Add, Text, x16 y112 w100 h15 vSongTime, 0:0:0 of 0:0:0
; Generated using SmartGUI Creator 4.0
Gui, Add, Text, +Disabled x260 y112 vText_Credits, Happytodd
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
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
#Include SoundFunctions.ahk
|
Now what I'm trying too do is add another of these codes into the library area, however because I got one already added into the media section it wont let me do it.
| Code: | | Gui, Add, Text, +Disabled x260 y112 vText_Credits, Happytodd |
Next once the songs are added they wont begin to play once double clicked library. How will I make them to play once double clicked. Thirdly under the library section where it says media file name on the bar at the top. How do I stretch it using the code so you can read the whole sentence. Sorry about all my problems I hope I'll get it working soon. Thanks guys! _________________
 |
|