MSLx Fanboy Posted July 4, 2005 Posted July 4, 2005 Thanks to that WMP test script in the beta, I was able to rewrite it to play a stream from a local radio station (Orlando, FL). It is a very small GUI, and can hide/show itself with F8/F9 (respectively). This is much nicer for me because of my automation of an AU3 "alarm clock" I've been working on (no more having to rely on firefox). If someone know how to get rid of the Maximize box (make it not show at all), let me know, I would like to put that in. expandcollapse popup#include <GuiConstants.au3> #region Object $oMyError = ObjEvent("AutoIt.Error","Quit") $oMediaplayer = ObjCreate("WMPlayer.OCX.7") If Not IsObj($oMediaplayer) Then Exit $oMediaplayer.Enabled = true $oMediaplayer.WindowlessVideo= true $oMediaPlayer.UImode="invisible" $oMediaPlayer.URL="http://players.eonstreams.com/FastAim/Player/Play.php?PulseID=14908515&SecurityKey=5553" $oMediaPlayControl=$oMediaPlayer.Controls $oMediaPlaySettings=$oMediaPlayer.Settings #endregion #region GUI GuiCreate("101.1 Music Player", 215, 100,(@DesktopWidth-215)/2, (@DesktopHeight-100)/2, -1) GuiCtrlCreateLabel("Real Rock 101.1 Streaming Music Player", 10, 10, 200, 20) $Volume = GuiCtrlCreateSlider(20, 30, 180, 20) GuiCtrlCreateLabel("Volume", 85, 50, 40, 20) GUICtrlSetData($Volume, 100) $Play = GuiCtrlCreateButton("Play", 30, 60, 50, 30) $Stop = GuiCtrlCreateButton("Stop", 120, 60, 50, 30) GuiSetState() $VolLevel = 100 HotKeySet("{F8}", "Hide") HotKeySet("{F9}", "Show") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Play $oMediaPlayControl.Play Case $msg = $Stop $oMediaPlayControl.Stop Case Else If GUICtrlread($Volume) <> $VolLevel Then $oMediaPlaySettings.Volume = GUICtrlRead($Volume) $VolLevel = GUICtrlRead($Volume) EndIf EndSelect WEnd Exit #endregion #region functions Func Quit() $oMediaPlayControl.Stop Exit EndFunc Func Hide() GUISetState(@SW_HIDE) EndFunc Func Show() GUISetState(@SW_SHOW) EndFunc #endregion Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
busysignal Posted July 5, 2005 Posted July 5, 2005 What version of Autoit is needed to run this ?? I am using .53 version.. Thanks..
MSLx Fanboy Posted July 5, 2005 Author Posted July 5, 2005 I'm on .55, but it should work with any beta version with COM support Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Valuater Posted July 6, 2005 Posted July 6, 2005 (edited) Thats Cool!!!!!!!!!! Played with it a little..... problem with removing the max/min is the GUI is not moveable.... but you already included {F8} and {F9} for hiding here ya go expandcollapse popup#include <GuiConstants.au3> #region Object $oMyError = ObjEvent("AutoIt.Error","Quit") $oMediaplayer = ObjCreate("WMPlayer.OCX.7") If Not IsObj($oMediaplayer) Then Exit $oMediaplayer.Enabled = true $oMediaplayer.WindowlessVideo= true $oMediaPlayer.UImode="invisible" $oMediaPlayer.URL="http://players.eonstreams.com/FastAim/Player/Play.php?PulseID=14908515&SecurityKey=5553" $oMediaPlayControl=$oMediaPlayer.Controls $oMediaPlaySettings=$oMediaPlayer.Settings #endregion #region GUI ;GuiCreate("101.1 Music Player", 215, 100,(@DesktopWidth-215)/2, (@DesktopHeight-100)/2, -1) GuiCreate("101.1 Music Player", 215, 100,(@DesktopWidth-215)/2, (@DesktopHeight-100)/2, BitOR($WS_POPUP,$WS_DLGFRAME),$WS_EX_TOPMOST); dev/null GuiCtrlCreateLabel("Real Rock 101.1 Streaming Music Player", 10, 10, 200, 20) ;GUICtrlSetFont(-1, 8, 650) GUICtrlSetColor(-1, 0xff0000) $Volume = GuiCtrlCreateSlider(20, 30, 180, 20) GuiCtrlCreateLabel("Volume", 85, 50, 40, 20) GUICtrlSetColor(-1, 0xff) GUICtrlSetData($Volume, 100) $Play = GuiCtrlCreateButton("Play", 30, 70, 50, 25) $Stop = GuiCtrlCreateButton("Stop", 130, 70, 50, 25) GuiSetState() $VolLevel = 100 HotKeySet("{F8}", "Hide") HotKeySet("{F9}", "Show") HotKeySet("{ESC}", "Quit") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Play $oMediaPlayControl.Play Case $msg = $Stop $oMediaPlayControl.Stop Case Else If GUICtrlread($Volume) <> $VolLevel Then $oMediaPlaySettings.Volume = GUICtrlRead($Volume) $VolLevel = GUICtrlRead($Volume) EndIf EndSelect WEnd Exit #endregion #region functions Func Quit() $oMediaPlayControl.Stop Exit EndFunc Func Hide() GUISetState(@SW_HIDE) EndFunc Func Show() GUISetState(@SW_SHOW) EndFunc #endregion hope ya like 8) EDIT: added You already had a "quit" function on error checking, however end user had no exit with the removal of the max/min title/header....... so I added this HotKeySet("{ESC}", "Quit") Edited July 7, 2005 by Valuater
Westi Posted August 24, 2005 Posted August 24, 2005 How can we free the memory? The code is eating ~100kB/sec.
slipperylobster Posted August 24, 2005 Posted August 24, 2005 I like it! A nice addition to my treasure trove of scripts!
MSLx Fanboy Posted August 25, 2005 Author Posted August 25, 2005 @Valuater - AutoIt GUIs automatically close with ESC if the window is visible and the Opt() isn't changed for it. @Westi - There is a ReduceMemory() UDF written by jftuga Func _ReduceMemory($iPID = -1) Local $aHandle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', $iPID), $aReturn = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $aHandle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $aHandle[0]) Return $aReturn[0] EndFunc ;==>_ReduceMemory() Just add an AdLibEnable function, and in the OnAutoItExit, make sure to include AdLibDisable(). @slipperylobster - Thank you for your comments. Just a note, if you find any other streaming radio stations, you can replace the url in the script with that of the other stream. When I find time, I intend to allow for playing more than one radio station in one exe (INI file probably). Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
theguy0000 Posted August 25, 2005 Posted August 25, 2005 (edited) >Running: (3.1.1.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\hp\My Documents\AutoIt\radio.au3"C:\Documents and Settings\hp\My Documents\AutoIt\radio.au3 (9) : ==> Unable to parse line.: $oMediaplayer.Enabled = true $oMediaplayer.E^ ERROR>AutoIT3.exe ended. Edited August 25, 2005 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
MSLx Fanboy Posted August 25, 2005 Author Posted August 25, 2005 (edited) You're running the Production version of AutoIt (3.1.1), you need to download the beta version from the v3 Developers forum (located in 3.1.1+ thread). I'll run down and get a link for you in a minute.Oh, yea, the reason is that COM support (Obj*()) was not included until beta.Edit: Beta Version Thread Edited August 25, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
theguy0000 Posted August 25, 2005 Posted August 25, 2005 thanks! The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
theguy0000 Posted August 25, 2005 Posted August 25, 2005 >Running: (3.1.1.68):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\hp\My Documents\AutoIt\radio.au3"C:\Documents and Settings\hp\My Documents\AutoIt\radio.au3 (54) : ==> Variable used without being declared.:$oMediaPlayControl.Stop ^ ERROR>AutoIT3.exe ended. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
MSLx Fanboy Posted August 25, 2005 Author Posted August 25, 2005 Is that using my script or Valuater's version? I looked at both, and they look correct to me, but I can't test it until I get home (about 5 hours from now). Send me a PM with the code you are using, I'll do a once-over on it. Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
theguy0000 Posted August 25, 2005 Posted August 25, 2005 i just copied and pasted the exact code in your first post into SciTE The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
MSLx Fanboy Posted August 26, 2005 Author Posted August 26, 2005 The script ran fine for me on the latest beta version (3.1.1.68), even though my connection right now is blocking the stream, the object still worked... I would double check to make sure you're running the beta version, not the prod (run straight from autoit3.exe if need be). Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Westi Posted August 26, 2005 Posted August 26, 2005 Ok, memory-eating is fixed, thanx MSLx Fanboy for the hint/link and jftuga for the code. The cpu-load is high, around 30% on my system. Can we reduce the cpu-load? I've no idea...
MSLx Fanboy Posted August 27, 2005 Author Posted August 27, 2005 Try putting a sleep(10) before the $msg = GUIGetMsg() line...I haven't tested it, but it should still work properly, and give your system a tiny break Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Mosquitos Posted August 28, 2005 Posted August 28, 2005 expandcollapse popup#include <GuiConstants.au3> $oMyError = ObjEvent("AutoIt.Error","Quit") $oMediaplayer = ObjCreate("WMPlayer.OCX.7") If Not IsObj($oMediaplayer) Then Exit $oMediaplayer.Enabled = true $oMediaplayer.WindowlessVideo= true $oMediaPlayer.UImode="invisible" $oMediaPlayControl=$oMediaPlayer.Controls $oMediaPlaySettings=$oMediaPlayer.Settings GuiCreate("Online Radio Jukebox", 215, 140, -1, -1, BitOR($WS_POPUP,$WS_DLGFRAME),$WS_EX_TOPMOST) GuiCtrlCreateLabel("Online Radio Jukebox", 55, 10, 200, 20) GUICtrlSetColor(-1, 0xff0000) $combo_name = GuiCtrlCreateCombo("", 20, 30, 175, 20) GuiCtrlSetData($combo_name, "Real Rock 101.1|Studio Brussel|Donna|Q-Music|4Fm|Contact|C-Dance|TopRadio|SkyRadio|Tmf|Noordzee|Veronica|BNN-Fm|Be-One|Oradio") $Volume = GuiCtrlCreateSlider( 17,110, 180, 20) GuiCtrlCreateLabel("Volume", 85, 95, 40, 20) GUICtrlSetColor(-1, 0xff) GUICtrlSetData($Volume, 100) $Play = GuiCtrlCreateButton("Play", 30, 60, 50, 25) $Stop = GuiCtrlCreateButton("Stop", 80, 60, 50, 25) $Cancel = GuiCtrlCreateButton("Exit", 130, 60, 50, 25) GuiSetState() $VolLevel = 100 HotKeySet("{F8}", "Hide") HotKeySet("{F9}", "Show") While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $combo_name $Radio = GuiCtrlRead($combo_name) If $Radio = "Real Rock 101.1" Then $oMediaPlayer.URL="http://players.eonstreams.com/FastAim/Player/Play.php?PulseID=14908515&SecurityKey=5553" EndIf If $Radio = "Studio Brussel" Then $oMediaPlayer.URL="mms://streampower.belgacom.be/stubruhigh" EndIf If $Radio = "Donna" Then $oMediaPlayer.URL="mms://streampower.belgacom.be/donnahigh" EndIf If $Radio = "Q-Music" Then $oMediaPlayer.URL="http://www.q-music.be/asx/phpasx/qahi.asx" EndIf If $Radio = "4Fm" Then $oMediaPlayer.URL="mms://wm.streampower.be/4fm" EndIf If $Radio = "Contact" Then $oMediaPlayer.URL="mms://mediaserver02.cybernet.be/contactnl" EndIf If $Radio = "C-Dance" Then $oMediaPlayer.URL="http://www.c-dance.be/stream_high.asx" EndIf If $Radio = "TopRadio" Then $oMediaPlayer.URL="http://www.topradio.be/new/website/topradioHigh.asx" EndIf If $Radio = "SkyRadio" Then $oMediaPlayer.URL="http://cinecast.capcave.com/streams/SkyRadio/SkyRadio.asx" EndIf If $Radio = "Tmf" Then $oMediaPlayer.URL="http://stream.tmf.nl/asx/tmf_audio.asp" EndIf If $Radio = "Noordzee" Then $oMediaPlayer.URL="mms://hollywood.win2k.vuurwerk.nl/noordzee" EndIf If $Radio = "Veronica" Then $oMediaPlayer.URL="http://cinecast.capcave.com/streams/RadioVeronica/RadioVeronica.asx" EndIf If $Radio = "BNN-Fm" Then $oMediaPlayer.URL="http://wmplayer.bnn.fm" EndIf If $Radio = "Be-One" Then $oMediaPlayer.URL="http://www.beoneradio.be/modules/desktop/streaming/asx.aspx?sid=1" EndIf If $Radio = "Oradio" Then $oMediaPlayer.URL="http://www.oradio.be/stream/livestream.asx" EndIf Case $msg = $Cancel $oMediaPlayControl.Stop Exit Case $msg = $Play $oMediaPlayControl.Play Case $msg = $Stop $oMediaPlayControl.Stop Case Else If GUICtrlread($Volume) <> $VolLevel Then $oMediaPlaySettings.Volume = GUICtrlRead($Volume) $VolLevel = GUICtrlRead($Volume) EndIf EndSelect WEnd Func Hide() GUISetState(@SW_HIDE) EndFunc Func Show() GUISetState(@SW_SHOW) EndFunc Exit Sapiente vince, rex, noli vincere ferro!
MSLx Fanboy Posted August 28, 2005 Author Posted August 28, 2005 Looks nice, you may want to look into the Switch syntax to make all of those if...endif statements much smaller Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
Westi Posted August 29, 2005 Posted August 29, 2005 Can we read statistics, like bandwith, played title or error messages(server full)? @Mosquitos: very nice script, but the volume at start is not set to the actual value. So 100 is maybe a little bit loud instead of ... GUICtrlSetData($Volume, 100) ... $VolLevel = 100 insert $VolLevel = $oMediaPlaySettings.Volume GUICtrlSetData($Volume, $VolLevel)
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