nobbe Posted January 28, 2009 Posted January 28, 2009 (edited) Have Fun - new : webradio save webradio to local [autoit]#cs ---------------------------------------------------------------------------- Sample code to MPLAYER media player modes are : files : play & later -- sort files in directories web : play & dump web radio in local mp3s requires ======== mplayer.exe from www.mplayerhq.hu mediainfo.dll from http://mediainfo.sourceforge.net a "settings.ini" file containing proxy like [settings] proxy=http_proxy://proxy:80/ webradio http://www.shoutcast.com/ hits 977 http://scfire-ntc-aa09.stream.aol.com:80/stream/1074 swr3.de http://edge.live.mp3.mdn.newmedia.nacamar.net/swr3live/livestream.mp3 dasding.de http:\\62.27.44.15:80\swrdasdinglive\livestream.mp3 by nobbe (2009) credits Emanuel "Datenshi" Lindgren #ce ---------------------------------------------------------------------------- #include <GUIConstants.au3> #include <String.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <SliderConstants.au3> #include <Misc.au3> ; ---- my udf for TAG info ;; #include "_media_tag_info.au3"; #NoTrayIcon Opt("GUICloseOnESC", 0) Opt("OnExitFunc", "ExitFunc") Global $WM_DROPFILES = 0x233 Global $gaDropFiles[1], $str = "" GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC") Global $glob_pause = 0 Global $glob_muted = 0 Global $glob_volume = 50; $adlibtimer = 250 $dll = DllOpen("user32.dll") ; kill previous task of mplayers.. While ProcessExists("mplayer.exe"); ProcessClose("mplayer.exe") WEnd ; read ini settings -- proxy Global $inilocation = @ScriptDir & "\settings.ini" ; Global $global_proxy = IniRead($inilocation, "settings", "proxy", "") ; ; ; #Region ### START Koda GUI section ### $GUI = GUICreate("Player", 760, 599, 512, 302, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE)) $Rewind = GUICtrlCreateButton("<<", 16, 490, 75, 25) $Button_Pause = GUICtrlCreateButton("Pause", 92, 490, 75, 25, 0) $Forward = GUICtrlCreateButton(">>", 169, 490, 75, 25, 0) $PosSlider = GUICtrlCreateSlider(5, 430, 630, 30, BitOR($TBS_AUTOTICKS,$TBS_BOTH)) $Volume = GUICtrlCreateSlider(392, 485, 113, 30, BitOR($TBS_AUTOTICKS,$TBS_BOTH)) $Mute = GUICtrlCreateIcon("shell32.dll", -169, 520, 485, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP)) $TabSheet = GUICtrlCreateTab(10, 15, 680, 390) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabItem1 = GUICtrlCreateTabItem("Files") $glob_titel_label = GUICtrlCreateLabel("Drop 1 file on Gui", 16, 46, 600, 20) GUICtrlSetFont(-1, 12, 800, 0, "Arial Bold") $glob_time_label = GUICtrlCreateLabel("", 16, 81, 600, 20) GUICtrlSetFont(-1, 12, 800, 0, "Arial Bold") $TabItem2 = GUICtrlCreateTabItem("Webradio") GUICtrlSetState(-1,$GUI_SHOW) $glob_titel_label_web = GUICtrlCreateLabel("Enter URL", 16, 46, 600, 20) GUICtrlSetFont(-1, 14, 800, 0, "Arial Bold") $glob_time_label_web = GUICtrlCreateLabel("", 16, 169, 600, 20) GUICtrlSetFont(-1, 14, 800, 0, "Arial Bold") $edit_webradio_link = GUICtrlCreateInput("http://", 16, 80, 601, 21) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $chkbtn_proxy = GUICtrlCreateCheckbox("use Proxy", 24, 112, 89, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $btn_webradio_listen = GUICtrlCreateButton("Listen", 152, 104, 75, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $btn_webradio_save = GUICtrlCreateButton("Save to local MP3", 232, 104, 147, 25, 0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateTabItem("") #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW) ; --- end gui GUICtrlSetLimit($Volume, "100", "0") GUICtrlSetLimit($PosSlider, "100", "0") GUICtrlSetData($Volume, $glob_volume) GUICtrlSetData($PosSlider, "0") $mplayerpid = -1; AdlibEnable("adlib", $adlibtimer) While 1 $nMsg = GUIGetMsg() Switch $nMsg ; listen to webradio Case $btn_webradio_listen _listen_webradio() ; save webradio to local MP3 Case $btn_webradio_save _save_webradio() Case $Volume If $mplayerpid Then $glob_volume = GUICtrlRead($Volume) ; StdinWrite($mplayerpid, "volume " & $glob_volume & " 1" & @LF) If $glob_muted = 1 Then StdinWrite($mplayerpid, "mute 0" & @LF) GUICtrlSetImage($Mute, "shell32.dll", 277) $glob_muted = 0 EndIf EndIf Case $PosSlider StdinWrite($mplayerpid, "seek " & GUICtrlRead($PosSlider) & " 1" & @LF) StdinWrite($mplayerpid, "get_property percent_pos" & @LF) $c = StdoutRead($mplayerpid) If StringInStr($c, "ANS_percent_pos=") And _IsPressed(01, $dll) = 0 Then $tmp = _StringBetween($c, "ANS_percent_pos=", @CRLF) $percpos = StringStripWS($tmp[0], 7) GUICtrlSetData($PosSlider, $percpos) EndIf Case $Mute If $mplayerpid Then If $glob_muted = 0 Then StdinWrite($mplayerpid, "mute 1" & @LF) GUICtrlSetImage($Mute, "shell32.dll", 240) $glob_muted = 1 Else StdinWrite($mplayerpid, "mute 0" & @LF) GUICtrlSetImage($Mute, "shell32.dll", 277) $glob_muted = 0 EndIf EndIf Case $Forward StdinWrite($mplayerpid, "seek +5" & @LF) $glob_pause = 0 Case $Rewind StdinWrite($mplayerpid, "seek -5" & @LF) $glob_pause = 0 Case $Button_Pause If $glob_pause = 0 Then StdinWrite($mplayerpid, "pause" & @LF) $glob_pause = 1 ElseIf $glob_pause = 1 Then StdinWrite($mplayerpid, "pause" & @LF) $glob_pause = 0 EndIf Case $GUI_EVENT_CLOSE ProcessClose($mplayerpid) Exit EndSwitch WEnd ; ; every --- Func Adlib() Local $tmp_time_rest Local $total_time Local $current_time Local $pos Local $max Local $tmp_time If ProcessExists($mplayerpid) Then $pos = 0 $max = 0 $cachefill = "N/A" If $mplayerpid And $glob_pause = 0 Then StdinWrite($mplayerpid, "get_property percent_pos" & @LF) StdinWrite($mplayerpid, "get_time_pos" & @LF) StdinWrite($mplayerpid, "get_time_length" & @LF) $c = StdoutRead($mplayerpid) ConsoleWrite($c) If StringInStr($c, "ANS_percent_pos=") And _IsPressed(01, $dll) = 0 Then $tmp = _StringBetween($c, "ANS_percent_pos=", @CRLF) $percpos = StringStripWS($tmp[0], 7) GUICtrlSetData($PosSlider, $percpos) EndIf If StringInStr($c, "ANS_TIME_POSITION") > 0 Then $tmp = _StringBetween($c, "ANS_TIME_POSITION=", @CRLF) $pos = StringStripWS($tmp[0], 7) EndIf If StringInStr($c, "ANS_LENGTH=") > 0 Then $tmp = _StringBetween($c, "ANS_LENGTH=", @CRLF) $max = StringStripWS($tmp[0], 7) EndIf If $max <> 0 And $pos <> 0 Then $tmp_time = Int($pos) $sec2time_hour = Int($tmp_time / 3600) $sec2time_min = Int(($tmp_time - $sec2time_hour * 3600) / 60) $sec2time_sec = $tmp_time - $sec2time_hour * 3600 - $sec2time_min * 60 $current_time = StringFormat('%02d:%02d:%02d', $sec2time_hour, $sec2time_min, $sec2time_sec) ; gesamt zeit Edited January 29, 2009 by nobbe
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