Xand3r Posted June 12, 2007 Share Posted June 12, 2007 (edited) so my little media player using wmmedia ,multiple accept files,double click and others:) i also uploaded all the other libs let me know what u think expandcollapse popupGlobal $VolOld=0 $duration=0 $old=0 Opt("WinTitleMatchMode" , 1) Opt("OnExitFunc" , "quit") Global $play=0 ; Script Start - Add your code below here $sFilename="" Dim $title[1000],$Obj[10000] Dim $files[10000],$num[10000] #include<Array.au3> #include<GUIList.au3> #include <GUIConstants.au3> #include<WMMedia.au3> #include<multiple.au3> $firsthit=0 Global $songs[10000][13] $oldpos=0 Global $fn=0 Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Alex Player", 509, 405, 200, 100, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_GROUP,$WS_BORDER), BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_WINDOWEDGE,$WS_EX_ACCEPTFILES)) GUISetBkColor("black") GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") GUISetOnEvent($GUI_EVENT_DROPPED,"drop") $Group1 = GUICtrlCreateGroup("Playlist", 240, 8, 257, 361) GUICtrlSetFont($Group1, 8, 400, 0, "Comic Sans MS") GUICtrlSetBkColor($Group1, 0xC0C0C0) $List1 = GUICtrlCreateList("", 248, 24, 241, 336,$LBS_STANDARD) GUICtrlSetBkColor($List1 , 0x111199) #include"dclick.au3" ;&+*+&+^+@$(*)@&$((*&^(*#&@(*&$(*@ Playlist menu $menu1=GUICtrlCreateContextMenu ($List1) $delete=GUICtrlCreateMenuitem("Delete" , $menu1) $play=GUICtrlCreateMenuitem("Play" , $menu1) $info=GUICtrlCreateMenuitem("Info" ,$menu1) ;*++*+**++**++**++*++**++**++**++**++**++**++**++**++**++** ;EVENTS FOR PLAYLIST MENU GUICtrlSetOnEvent($info , "info") GUICtrlSetOnEvent($delete , "delete") GUICtrlSetOnEvent($play , "Button1Click") ;XOXOXOXOXOXOXOXOXOXOXOXOOOXXOXXXXOXOXOXOXOXXOXOXOXOXOXOXOX GUICtrlSetOnEvent($List1, "List1Click") GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Control", 16, 16, 209, 177) $Button1 = GUICtrlCreateButton("Play", 32, 80, 33, 17, $BS_FLAT,$WS_EX_TRANSPARENT ) GUICtrlSetColor(-1 , 0x0000ff) GUICtrlSetOnEvent($Button1, "Button1Click") $Button2 = GUICtrlCreateButton("Stop", 72, 80, 33, 17, $BS_FLAT,$WS_EX_TRANSPARENT ) GUICtrlSetColor(-1 , 0x0000ff) GUICtrlSetOnEvent($Button2, "Button2Click") $Button3 = GUICtrlCreateButton("Pause", 112, 80, 45, 17, $BS_FLAT,$WS_EX_TRANSPARENT ) GUICtrlSetColor(-1 , 0x0000ff) GUICtrlSetOnEvent($Button3, "Pausep") $Button4 = GUICtrlCreateButton("Open", 164, 80, 33, 17,$BS_FLAT,$WS_EX_TRANSPARENT ) GUICtrlSetColor(-1 , 0x0000ff) GUICtrlSetOnEvent($Button4, "Button4Click") $Input1 = GUICtrlCreateInput("", 24, 40, 193, 21,-1) GUICtrlSetState($Input1 , $GUI_DISABLE) ;adsf ;fsadf ;fsad ;asd ;sadf ;askfhksadf GUICtrlSetState($List1 , $GUI_DROPACCEPTED) ;fsadf ;sadfsad ;sadf ;sadfsdf ;asdfsadf GUICtrlSetBkColor($Input1, 0x0000ff) GUICtrlSetOnEvent($Input1, "Input1Change") $Slider1 = GUICtrlCreateSlider(24, 104, 89, 25,-1,$WS_EX_TRANSPARENT ) ;GUICtrlSetOnEvent($Slider1, "Slider1Change") GUICtrlSetTip($Slider1, "Volume") GUICtrlSetData($Slider1 , 50) $clear=GUICtrlCreateButton("Clear" , 120 , 104 , 40 , 20,$BS_FLAT,$WS_EX_TRANSPARENT ) GUICtrlSetColor($clear, 0x0000ff) GUICtrlSetOnEvent($clear , "clear") $Slider2 = GUICtrlCreateSlider(18, 136, 205, 25) $time = GUICtrlCreateLabel("00:00" , 96 , 165,40,20) GUICtrlSetColor($time , 0x0000ff) GUICtrlSetOnEvent($Slider2, "Slider2Change") GUICtrlSetLimit($Slider2 , 100) GUICtrlSetTip($Slider2, "Progress") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) ;ACTUAL MENU $a=GUICtrlCreateMenu("&Menu") $exit=GUICtrlCreateMenuitem("E&xit" , $a) GUICtrlSetOnEvent($exit,"quit") $b=GUICtrlCreateMenu("H&elp") $about=GUICtrlCreateMenuitem("A&bout" , $B) GUICtrlSetOnEvent($about , "about") GUICtrlSetBkColor($Slider1,"black") GUICtrlSetBkColor($Slider2,"black") GUICtrlSetState($Button1, $GUI_DISABLE) ;INPUT1 color GUICtrlSetColor($Input1 , 0x000000) $minx=0 $secx=0 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx LOOP xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx onload() While 1 Sleep(1) If GuiCtrlRead($Slider1) <> $VolOld Then WmSetVolume(GUICtrlRead($Slider1)) $VolOld = GuiCtrlRead($Slider1) ToolTip(GUICtrlRead($Slider1)); EndIf $ggci = GUIGetCursorInfo($Form1) If $ggci[2] = 0 Then ToolTip("") EndIf If $fn>0 Then $i=_GUICtrlListSelectedIndex($List1) If $i<>$LB_ERR Then If IsObj($Obj[$i]) Then $percent=Round(WMGetPosition()*100/$duration) If $percent<>$oldpos Then $oldpos=$percent $down=GUIGetCursorInfo($Form1) If Not ($down[4]=$Slider2 And $down[2]=1) Then GUICtrlSetData($Slider2 , $percent) EndIf EndIf $aux=Round($duration-WMGetPosition()) $min=($aux-Mod($aux,60))/60 $sec=$aux-$min*60 If $min<10 Then $min=0&$min If $sec<10 Then $sec=0&$sec If $minx<> $min Or $sec<>$secx Then scrolltitle() $minx=$min $secx=$sec GUICtrlSetData($time , $min&":"&$sec) If $play=1 Then If WMGetState() = "Stopped" Then If _GUICtrlListSelectedIndex($List1)=_GUICtrlListCount($List1)-1 Then $pos=0 Else $pos=_GUICtrlListSelectedIndex($List1)+1 EndIf _GUICtrlListSelectIndex($List1,$pos) Button1Click() EndIf EndIf EndIf EndIf EndIf EndIf WEnd ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Func Button1Click() If IsObj($Obj[$fn-1]) Then $pos=_GUICtrlListSelectedIndex($List1) If $files[$pos]<>"" Then $pos=_GUICtrlListSelectedIndex($List1) Global $duration=WMGetDuration($Obj[$pos]) WMPlay($files[$pos]) If Not @error Then GUICtrlSetData($Input1 , GUICtrlRead($List1)) WinSetTitle("Alex Player" , "" , "Alex Player: " &GUICtrlRead($List1)) EndIf EndIf If WmGetAlbum($Obj[$fn-1])<>"" Then GUICtrlSetData($Input1,GUICtrlRead($Input1)&"("&WmGetAlbum($Obj[$fn-1])&")") $play=1 EndIf EndFunc Func Pausep() GUICtrlSetData($Button3 , "Resume") WMPause() GUICtrlSetOnEvent($Button3 , "Resume") EndFunc Func Resume() GUICtrlSetData($Button3 , "Pause") WMResume() GUICtrlSetOnEvent($Button3 , "Pausep") EndFunc Func Button2Click() $play=0 WMStop() EndFunc Func Button4Click() $sFilename = FileOpenDialog("Select a file to use.", "", "Mp3s(*.mp3)|Wave Sound Files(*.wav)", 7) If $sFilename="" Then Return EndIf openfile($sFilename) EndFunc Func openfile($file) $loc=StringSplit($file,"|") WMStartPlayer() If $loc[0]<>1 Then For $i=2 To $loc[0] $Obj[$fn] = WMOpenFile($loc[$i]) $files[$fn]=$loc[1]&"\"&$loc[$i] $aux=Round(WMGetDuration($Obj[$fn])) $min=($aux-Mod($aux,60))/60 $sec=$aux-$min*60 $num[$fn]=WmGetArtist($Obj[$fn])&"-"&WmGetTitle($Obj[$fn])&"("&$min&":"&$sec&")" $fn+=1 addlistitem() Next Return EndIf $Obj[$fn] = WMOpenFile($loc[1]) $files[$fn]=$loc[1] $aux=Round(WMGetDuration($Obj[$fn])) $min=($aux-Mod($aux,60))/60 $sec=$aux-$min*60 $num[$fn]=WmGetArtist($Obj[$fn])&"-"&WmGetTitle($Obj[$fn])&"("&$min&":"&$sec&")" $fn+=1 addlistitem() EndFunc Func Form1Close() Exit EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func Input1Change() MsgBox(0,"" , "") EndFunc Func List1Click() If $firsthit=0 Then $firsthit=1 GUICtrlSetState($Button1 , $GUI_ENABLE) EndIf EndFunc Func Pic1Click() MsgBox(0,"" , "") EndFunc Func Slider2Change() WMSetPosition(GUICtrlRead($Slider2)/100*$duration) EndFunc Func addlistitem() If $fn>0 Then $aux=Round(WMGetDuration($Obj[$fn-1])) $min=($aux-Mod($aux,60))/60 $sec=$aux-$min*60 _GUICtrlListInsertItem($List1,$fn&"-"&WmGetArtist($Obj[$fn-1])&"-"&WmGetTitle($Obj[$fn-1])&"("&$min&":"&$sec&")",$fn-1) EndIf EndFunc Func scrolltitle() If GUICtrlRead($Input1)<>"" Then $text=GUICtrlRead($Input1) $split=StringSplit($text,"") $temp=$split[1] For $i=1 To $split[0]-1 $split[$i]=$split[$i+1] Next $split[$i]=$temp $msg="" For $i=1 To $split[0] $msg=$msg&$split[$i] Next GUICtrlSetData($Input1,$msg) WinSetTitle("Alex Player" , "" , "Alex Player: "&$msg) EndIf EndFunc Func delete() If GUICtrlRead($List1)<>"" Then $i=_GUICtrlListSelectedIndex($List1) _ArrayDelete($num ,$i) _ArrayDelete($files , $i) _ArrayDelete($Obj, $i) _GUICtrlListDeleteItem($List1 , $i) $fn-=1 EndIf EndFunc Func info() $i=_GUICtrlListSelectedIndex($List1) MsgBox(0, "Song Data", "Duration - " & WMGetDuration($Obj[$i]) & @LF & _ "Artist - " & WmGetArtist($Obj[$i]) & @LF & _ "Album - " & WmGetAlbum($Obj[$i]) & @LF & _ "Title - " & WmGetTitle($Obj[$i]) & @LF & _ "Bitrate - " & WmGetBitrate($Obj[$i]) & @LF & _ "MediaType - " & WmGetMediaType($Obj[$i]) & @LF & _ "FileSize - " & WmGetFileSize($Obj[$i]) & @LF & _ "FileType - " & WmGetFileType($Obj[$i]) & @LF & _ "Category - " & WMGetCategory($Obj[$i]) & @LF & _ "Genre - " & WMGetGenre($Obj[$i]) & @LF & _ "Year - " & WMGetYear($Obj[$i]) & @LF & _ "State - " & WMGetState()) EndFunc Func quit() onexit() WMClosePlayer() Exit EndFunc Func about() MsgBox(64,"About" , "Alex player"&@LF& _ "Made by: alexmadman"&@LF& _ "Build program:autoit(www.autoitscript.com)"&@LF& _ "Custom libs: WMmedia.au3"&@LF& _ " Lazycat's multiple drop") EndFunc Func onexit() ;check number of open files and if 0 exit the func If $fn=0 Then Return ;open file for data Local $file=FileOpen("C:\Documents and Settings\Alex\Desktop\autoit\wmp\playerdata.dat",2) If $file=-1 Then ;check for file open MsgBox(0 , "" , "Error") Return EndIf ConsoleWrite("| file opened ") ;save the volume FileWrite($file,$VolOld&@LF) ConsoleWrite("| wrote vol ") ;save the number of files in the playlist FileWrite($file , $fn&@LF) ConsoleWrite("| wrote num files ") ;save all the files in order For $i=0 to $fn-1 FileWrite($file,$files[$i]&@LF) Next ConsoleWrite("| wrote files ") FileClose($file) ConsoleWrite("| closed file"&@CRLF) EndFunc Func onload() ;try to open data file Local $file=FileOpen("C:\Documents and Settings\Alex\Desktop\autoit\wmp\playerdata.dat" , 0 ) If $file=-1 Then Return ;get the volume If FileGetSize("playerdata.dat")=0 Then Return $volz=FileReadLine($file) GUICtrlSetData($Slider1 , $volz) $numfiles=FileReadLine($file) ;MsgBox(0 , $volz , $numfiles) For $i=0 To $numfiles-1 $line=FileReadLine($file) openfile($line) ;MsgBox(0 , "" , $line) Next FileClose($file) GUICtrlSetState($Button1 , $GUI_ENABLE) EndFunc Func dclick() Button1Click() EndFunc Func drop() For $i = 0 To UBound($gaDropFiles) - 1 openfile($gaDropFiles[$i]) Next EndFunc Func clear() For $i=0 To $fn-2 _GUICtrlListSelectIndex($List1 , 0) delete() Next EndFunc Edit: P.S. dont mind all the Weird COmments it helps me look for stuff in the code faster Edited June 12, 2007 by alexmadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
nobbe Posted June 13, 2007 Share Posted June 13, 2007 hi i like it apart from the blue BG in the List, which is hard to read "black on dark blue" :-) i would add some suggestions: - your comment lines shouldnt be longer than 70 chars, copying the code into editor gave quite a few errors - the global settings should go into current directory - german xp doesnt have "C:\Documents and Settings\Alex\" - your controls should have "names" to make source better understandable $Button2 = GUICtrlCreateButton("Stop" better $BTN_STOP = GUICtrlCreateButton("Stop" for the player : -it would be nice to have a ">" next & previous file button - also the timedisplay would be nice to have : elapsed time / total time / remaining time - your code needs better structures . you have a mixture of declarations , assigments , dialogs ,etc ,you will see that code is much easier to read if you section it and keep all vars of the same type in the same section.. eg ---- Opt("WinTitleMatchMode" , 1) ---- #include<Array.au3> #include<GUIList.au3> now all includes .. --- Global $songs[10000][13] now all globals .. --- $Form1 = GUICreate("Alex Player", 509, 405, 200, 100, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_GROUP,$WS_BORDER), now all form related .. --- $minx=0 $secx=0 now all values... nob Link to comment Share on other sites More sharing options...
Xand3r Posted June 13, 2007 Author Share Posted June 13, 2007 (edited) thoose controls : $Button1 and..... were actualy made by koda ) and i was too lazy to rename them plus i know what each one does Edit: just finished that code last night at 2 am and.... that's how i work first the code than the cleaning and many vars and includes... must be done before of after something Edited June 13, 2007 by alexmadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
gseller Posted September 18, 2007 Share Posted September 18, 2007 WOW, after that reaming you took above... LOL I like your script. Great features! Like the scrolling title in the title bar and reading all the tag info. Tru, might be a bit messy but works good, something to be proud of. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now