LIMITER Posted January 12, 2008 Share Posted January 12, 2008 (edited) I made a mp3/wav player and i want to get the remaining time of an opened sound ... how can i do that ?Thx !expandcollapse popup#include <GUIConstants.au3> #include <GuiStatusBar.au3> #include <Sound.au3> #Include <GuiListView.au3> $cver = "2.0.0" AutoItSetOption("TrayMenuMode",1) TraySetToolTip("L|M|TER Media Player v. " & $cver) ;Download images InetGet("http://img167.imageshack.us/img167/2965/lmplogohq6.jpg",@TempDir & "\lmplogo.jpg", 1, 1) While @InetGetActive SplashTextOn("L|M|TER Media Player", "Welcome " & @UserName & " !" & " Please wait while LMP is loading .", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ..", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ...", 320,18, -1, -1, 1, "", 10) Sleep(500) Wend InetGet("http://www.imagehosting.com/out.php/i1478222_stop.bmp",@TempDir & "\stopb.bmp", 1, 1) While @InetGetActive SplashTextOn("L|M|TER Media Player", "Welcome " & @UserName & " !" & " Please wait while LMP is loading .", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ..", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ...", 320,18, -1, -1, 1, "", 10) Sleep(500) Wend InetGet("http://www.imagehosting.com/out.php/i1478172_pause.bmp",@TempDir & "\pauseb.bmp", 1, 1) While @InetGetActive SplashTextOn("L|M|TER Media Player", "Welcome " & @UserName & " !" & " Please wait while LMP is loading .", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ..", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ...", 320,18, -1, -1, 1, "", 10) Sleep(500) Wend InetGet("http://www.imagehosting.com/out.php/i1478210_play.bmp",@TempDir & "\playb.bmp", 1, 1) While @InetGetActive SplashTextOn("L|M|TER Media Player", "Welcome " & @UserName & " !" & " Please wait while LMP is loading .", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ..", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ...", 320,18, -1, -1, 1, "", 10) Sleep(500) Wend InetGet("http://www.imagehosting.com/out.php/i1478238_resume.bmp",@TempDir & "\resumeb.bmp", 1, 1) While @InetGetActive SplashTextOn("L|M|TER Media Player", "Welcome " & @UserName & " !" & " Please wait while LMP is loading .", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ..", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Welcome " & @UserName & " !" & " Please wait while LMP is loading ...", 320,18, -1, -1, 1, "", 10) Sleep(500) Wend ;Update check InetGet("http://limiter.evonet.ro/lmp-test.ver",@TempDir & "\lmp-test.ver", 1, 1) If @error Then MsgBox(32,"LMP Update","There was a problem contacting the server, try again later ...") While @InetGetActive SplashTextOn("L|M|TER Media Player", "Please wait while LMP is checking for updates .", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Please wait while LMP is checking for updates ..", 320,18, -1, -1, 1, "", 10) Sleep(500) SplashTextOn("L|M|TER Media Player", " Please wait while LMP is checking for updates ...", 320,18, -1, -1, 1, "", 10) Sleep(500) Wend SplashOff() $dat = FileOpen(@TempDir & "\lmp-test.ver",0) Global $nver = FileReadLine($dat,1) FileClose($dat) If $nver = $cver Then TrayTip("L|M|TER Media Player","There is no new version of LMP ...", 2, 1) sleep(3000) TrayTip("","",0) EndIf If $nver > $cver Then EndIf #Region ### START Koda GUI section ### Form=C:\AutoIt\LMP\lmp.kxf $gui = GUICreate("L|M|TER Media Player v. " & $cver & " - © 2008 L|M|TER", 565, 365, -1, -1) GUISetIcon("lmp.ico") $tab = GUICtrlCreateTab(8, 6, 548, 332) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHCENTER+$GUI_DOCKVCENTER) $lmp = GUICtrlCreateTabItem("L|M|TER Music Player") $logo = GUICtrlCreatePic(@TempDir & "\lmplogo.jpg", 56, 36, 447, 78) $text = GUICtrlCreateLabel("Please select a song to play :", 25, 120, 145, 18, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $file = GUICtrlCreateInput("", 25, 140, 246, 22) GUICtrlSetFont($file,default,800) $browse = GUICtrlCreateButton("Browse ...", 275, 140, 75, 22, 0) GUICtrlSetFont($browse,default,800) GUICtrlSetBkColor($browse,0xECE9D8) $progress = GUICtrlCreateProgress(25, 170, 510, 17, $PBS_SMOOTH) GUICtrlSetTip($progress,"Shows the current song length","L|M|TER Media Player",1,1) $play = GUICtrlCreateButton("", 25, 195, 30, 30,$BS_BITMAP) GUICtrlSetTip($play,"Play the selected song","L|M|TER Media Player",1,1) $stop = GUICtrlCreateButton("", 60, 195, 30, 30,$BS_BITMAP) GUICtrlSetTip($stop,"Stop the playing song","L|M|TER Media Player",1,1) $pause = GUICtrlCreateButton("", 95, 195, 30, 30,$BS_BITMAP) GUICtrlSetTip($pause,"Pause the playing song","L|M|TER Media Player",1,1) $resume = GUICtrlCreateButton("", 130, 195, 30, 30,$BS_BITMAP) GUICtrlSetTip($resume,"Resume the paused song","L|M|TER Media Player",1,1) $playlist = GUICtrlCreateListView("LIMITER Music Player Playlist", 25, 235, 510, 85) GUICtrlSendMsg(-1, 0x101E, 0, 505) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $about = GUICtrlCreateButton("About LMP", 460, 195, 75, 30, 0) GUICtrlSetFont($about,default,800) GUICtrlSetBkColor($about,0xECE9D8) $add = GUICtrlCreateButton("Add", 165, 195, 60, 30, 0) GUICtrlSetFont($add,default,800) GUICtrlSetBkColor($add,0xECE9D8) GUICtrlSetTip($add,"Add a song to the playlist","L|M|TER Media Player",1,1) $remove = GUICtrlCreateButton("Remove", 230, 195, 60, 30, 0) GUICtrlSetFont($remove,default,800) GUICtrlSetBkColor($remove,0xECE9D8) GUICtrlSetTip($remove,"Remove the selected song from the playlist","L|M|TER Media Player",1,1) $help = GUICtrlCreateButton("Help", 380, 195, 75, 30, 0) GUICtrlSetFont($help,default,800) GUICtrlSetBkColor($help,0xECE9D8) $elapsed = GUICtrlCreateLabel("Elapsed :", 410, 120, 120, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $remaining = GUICtrlCreateLabel("Remaining :", 410, 140, 120, 18) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $statusbox = GUICtrlCreateGroup("", 405, 110, 130, 50) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlCreateGroup("", -99, -99, 1, 1) $lpv = GUICtrlCreateTabItem("L|M|TER Picture Viewer") $text1 = GUICtrlCreateLabel("Coming Soon ... !", 210, 160, 123, 22) GUICtrlSetFont(-1, 11, 800, 0, "Arial") GUICtrlCreateTabItem("") $status = _GUICtrlStatusBar_Create($gui) _GUICtrlStatusBar_SetSimple($status) _GUICtrlStatusBar_SetText($status, "Welcome " & @UserName & " To L|M|TER Media Player ! ... © 2008 L|M|TER") GUICtrlSetImage($play,@TempDir & "\playb.bmp") GUICtrlSetImage($pause,@TempDir & "\pauseb.bmp") GUICtrlSetImage($stop,@TempDir & "\stopb.bmp") GUICtrlSetImage($resume,@TempDir & "\resumeb.bmp") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $sound = _SoundOpen("") $playlistsong = "" $test = "0" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _SoundClose($sound) _SoundClose($playlistsong) Exit Case $play Call("play") Case $browse Call("browse") Case $stop Call("stop") Case $pause Call("pause") Case $resume Call("resume") Case $remove EndSwitch If _SoundStatus($sound)="playing" Then $a = _SoundPos($sound,2) $b = _SoundLength($sound,2) $c = Round(($a / $B) * 100) $d = Round((($b - $a) / 1000) / 60) GUICtrlSetData($progress,$c) GUICtrlSetData($elapsed,"Elapsed : " & _SoundPos($sound)) EndIf WEnd Func browse() _GUICtrlStatusBar_SetText($status, "Status : File opened ...") $filep = FileOpenDialog("Select a file to play ...", @HomeDrive,"Music Files (*.mp3;*.wav)") If @error = 1 Then MsgBox(32,"L|M|TER Media Player","Please select a file !") _GUICtrlStatusBar_SetText($status, "Status : No file selected ...") GUICtrlSetData($file,"No file selected ...") EndIf GUICtrlSetData($file,$filep) $sound = _SoundOpen($filep) EndFunc Func play() $selected = GuiCtrlRead($playlist) $selected1 = GuiCtrlRead($selected) $playlistsong = StringTrimRight ($selected1, 1) _SoundPlay($playlistsong) $sp = _SoundPlay($sound) _GUICtrlStatusBar_SetText($status, "Status : Playing ...") EndFunc Func stop() GUICtrlSetData($progress,"0") GUICtrlSetData($elapsed,"Elapsed : ") GUICtrlSetData($remaining,"Remaining : ") $selected = GuiCtrlRead($playlist) $selected1 = GuiCtrlRead($selected) $playlistsong = StringTrimRight ($selected1, 1) _SoundStop($playlistsong) _SoundStop($sound) _GUICtrlStatusBar_SetText($status, "Status : Stopped ...") EndFunc Func pause() $selected = GuiCtrlRead($playlist) $selected1 = GuiCtrlRead($selected) $playlistsong = StringTrimRight ($selected1, 1) _SoundPause($playlistsong) _SoundPause($sound) _GUICtrlStatusBar_SetText($status, "Status : Paused ...") EndFunc Func resume() $selected = GuiCtrlRead($playlist) $selected1 = GuiCtrlRead($selected) $playlistsong = StringTrimRight ($selected1, 1) _SoundResume($playlistsong) _SoundResume($sound) _GUICtrlStatusBar_SetText($status, "Status : Playing ...") EndFunc Edited January 12, 2008 by LIMITER Link to comment Share on other sites More sharing options...
WolfWorld Posted January 12, 2008 Share Posted January 12, 2008 Round((_SoundLength($file,2) - _SoundPos($file,2)) * 1000),2) Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! 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