AutoHotkey Community

It is currently May 27th, 2012, 10:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: August 28th, 2007, 8:55 am 
Any idea how to extract such a stream:
http://www.last.fm/listen/artist/Black% ... larartists
to embed it within an AHK GUI?

IE4Ahk (and shrink the appearance of the AHK GUI to the size of the embbeded player) ?

:?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2007, 12:03 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
That would work I think, a quick test with the example from:

http://www.autohotkey.com/wiki/index.ph ... er_Control

Code:
#Include IEControl.ahk
#SingleInstance force

GoSub, GuiStart

Gui, +LastFound +Resize
Gui, Show, w400 h250 Center, WebBrowser
hWnd := WinExist()

CLSID_WebBrowser := "{8856F961-340A-11D0-A96B-00C04FD705A2}"
IID_IWebBrowser2 := "{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}"
pwb := CreateObject(CLSID_WebBrowser, IID_IWebBrowser2)

AtlAxAttachControl(pwb, hWnd)

IE_LoadURL(pwb, "http://www.last.fm/webclient/popup/?radioURL=lastfm%3A%2F%2Fartist%2FBlack%2520Rebel%2520Motorcycle%2520Club%2Fsimilarartists&resourceID=undefined&resourceType=undefined")
Return

GuiStart:
AtlAxWinInit()
CoInitialize()
Return


Also works if you play a local file with the embeded code from the
last.fm page

Code:
IE_LoadURL(pwb, "file:///c:/play.htm")


'All' you need now is a way to add favourites to this player and bob's your uncle...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2007, 1:43 pm 
Thx for your effort, unfortunately it's not working here. I can see that the page is loading (eggtimer), but it won't show up at the GUI.
Had a try with the widget page option too, same result.

If I start that local page via IE, it will get blocked via the IE 'active content' alert. Even if I confirm that alert, the page won't get loaded completely.

Any idea how to circumvent that (hopefully without I've to bend/change local company policy restricted IE settings)?

Thx mate :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 28th, 2007, 4:56 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
When I run the test script my firewall says Autohotkey is trying to access last.fm so that might be the page doesn't load fully.

Don't know how to solve it really... :(

I assume a AHK script with a UrlDownloadToFile doesn't work either?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 11:13 am 
While...
Code:
Run, iexplore "http://www.last.fm/widgets/popup/?url=artist`%2FJustin`%2520Timberlake`%2Fsimilarartists&colour=red&size=regular&autostart=1&from=popup&widget=radio&resize=0&height=240&width=234&resizable=no&scrollbars=no"

...is running/loading fine ...
Code:
IE_LoadURL(pwb, "http://www.last.fm/widgets/popup/?url=artist`%2FJustin`%2520Timberlake`%2Fsimilarartists&colour=red&size=regular&autostart=1&from=popup&widget=radio&resize=0&height=240&width=234&resizable=no&scrollbars=no")

... is stopping, once the player is loaded. The embedded Flash player component ignores the autostart option, and therefore needs to be activated manually using a right click (appskey), which is kinda annoying.

An IEControl.ahk issue ??


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 2:33 pm 
daonlyfreez has used cwebpage.dll to embed videos within a GUI.
But it looks like Flash is a little snippy once started within an AHK-GUI :cry:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 2:54 pm 
daonlyfreez' : [AHKOnlineVideo] :wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 5:07 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 969
Location: Frisia
Something like this?

Code:
  #NoEnv
  SendMode Input
  SetWorkingDir %A_ScriptDir%
 
  #Include %A_ScriptDir%\CoHelper.ahk
  #Include %A_ScriptDir%\IEControl.ahk
 
  winX = 10
  winY = 10
  winW = 160
  winH = 240
 
  OnExit, Exiting
 
  Gui, +Lastfound +Resize
  hWnd := WinExist()
 
  hIEC := IE_Add(hWnd, 0, 0, winW, winH - 30)
 
  Gui, Show, x10 h10 w%winW% h%winH%, Mini last.fm Player

  URL2Load = file://%A_ScriptDir%/lastfm.html
  StringReplace, URL2Load, URL2Load, \, /, All
 
  Gosub, GoURL

  ;MsgBox Page loaded!

Return ; End of AutoExecute section

; Load HTML
GoHTML:
   IE_LoadHTML(hIEC, HTML2Load)
   Gosub, WaitIEIsDone
   HTML2Load =
Return

GoURL:
   IE_LoadURL(hIEC, URL2Load)
   Gosub, WaitIEIsDone
   URL2Load =
Return

; Wait for loaded
WaitIEIsDone:
   Loop
   {
      If (IE_ReadyState(hIEC) = 4) && !IE_Busy(hIEC)
         Break
      Sleep 100
   }
Return

GuiSize:
   WinGetPos, nowX, nowY, nowW, nowH, ahk_id %hWnd%
   nowW := nowW - 10
   nowH := nowH - 28
   IE_Move(hIEC, 0, 0, nowW, nowH)
Return

Esc::
GuiClose:
Exiting:
   Release(hIEC)
   Gui Destroy
   CoUninitialize()
   AtlAxWinTerm()
   ExitApp
Return

!^r::Reload ; for debugging


Needs a basic html-file with the code from the widget generator from LastFM, and CoHelper.ahk and IEControl.ahk

lastfm.html:

Quote:
<html>
<head>
</head>
<body>

<style type="text/css">table.lfmWidget20070829153340 td {margin:0 !important;padding:0 !important;border:0 !important;}table.lfmWidget20070829153340 tr.lfmHead a:hover {background:url(http://cdn.last.fm/widgets/images/en/he ... i_grey.png) no-repeat 0 0 !important;}table.lfmWidget20070829153340 tr.lfmEmbed object {float:left;}table.lfmWidget20070829153340 tr.lfmFoot td.lfmConfig a:hover {background:url(http://cdn.last.fm/widgets/images/en/footer/grey.png) no-repeat 0px 0 !important;;}table.lfmWidget20070829153340 tr.lfmFoot td.lfmView a:hover {background:url(http://cdn.last.fm/widgets/images/en/footer/grey.png) no-repeat -85px 0 !important;}table.lfmWidget20070829153340 tr.lfmFoot td.lfmPopup a:hover {background:url(http://cdn.last.fm/widgets/images/en/footer/grey.png) no-repeat -159px 0 !important;}</style>
<table class="lfmWidget20070829153340" cellpadding="0" cellspacing="0" border="0" style="width:110px;"><tr class="lfmHead"><td><a title="Music like Black Rebel Motorcycle Club" href="http://www.last.fm/listen/artist/Black%2520Rebel%2520Motorcycle%2520Club/similarartists" target="_blank" style="display:block;overflow:hidden;height:20px;width:110px;background:url(http://cdn.last.fm/widgets/images/en/he ... i_grey.png) no-repeat 0 -20px;text-decoration:none;"></a></td></tr><tr class="lfmEmbed"><td><object width="110" height="140" style="float:left;" data="http://cdn.last.fm/widgets/radio/14.swf" type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"> <param name="movie" value="http://cdn.last.fm/widgets/radio/14.swf" /> <param name="flashvars" value="lfmMode=radio&amp;radioURL=artist%2FBlack%2520Rebel%2520Motorcycle%2520Club%2Fsimilarartists&amp;title=Music+like+Black+Rebel+Motorcycle+Club&amp;theme=grey&amp;autostart=1&amp;lang=en" /> <param name="bgcolor" value="#999999" /> <param name="quality" value="high" /> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowNetworking" value="all" /> <embed src="http://cdn.last.fm/widgets/radio/14.swf" flashvars="lfmMode=radio&amp;radioURL=artist%2FBlack%2520Rebel%2520Motorcycle%2520Club%2Fsimilarartists&amp;title=Music+like+Black+Rebel+Motorcycle+Club&amp;theme=grey&amp;autostart=1&amp;lang=en" bgcolor="#999999" width="110" height="140" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" allowScriptAccess="sameDomain" allowNetworking="all"> </embed> </object></td></tr><tr class="lfmFoot"><td style="background:url(http://cdn.last.fm/widgets/images/footer_bg/grey.png) repeat-x 0 0;text-align:right;"><table cellspacing="0" cellpadding="0" border="0" style="width:110px;"><tr><td class="lfmConfig"><a href="http://www.last.fm/widgets/?url=artist%2FBlack%2520Rebel%2520Motorcycle%2520Club%2Fsimilarartists&amp;colour=grey&amp;size=mini&amp;autostart=1&amp;from=code&amp;widget=radio" title="Get your own widget" target="_blank" style="display:block;overflow:hidden;width:85px;height:20px;float:right;background:url(http://cdn.last.fm/widgets/images/en/footer/grey.png) no-repeat 0px -20px;text-decoration:none;"></a></td><td class="lfmPopup"style="width:25px;"><a href="http://www.last.fm/widgets/popup/?url=artist%2FBlack%2520Rebel%2520Motorcycle%2520Club%2Fsimilarartists&amp;colour=grey&amp;size=mini&amp;autostart=1&amp;from=code&amp;widget=radio&amp;resize=1" title="Load this radio in a pop up" target="_blank" style="display:block;overflow:hidden;width:25px;height:20px;background:url(http://cdn.last.fm/widgets/images/en/footer/grey.png) no-repeat -159px -20px;text-decoration:none;" onclick="window.open(this.href + '&amp;resize=0','lfm_popup','height=240,width=160,resizable=yes,scrollbars=yes'); return false;"></a></td></tr></table></td></tr></table>

</body>
</html>


:shock: Apologies for the non-wrapping :?

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 8:34 pm 
Hi daonlyfreez :D
I've tried your script, and - it behaves the same like mine, which isn't that good. Once the embedded player gets initialized (IE_Control has already confirmed to have finished loading) it won't load the stream, and starts playin.

Two interesting things I've encountered.

1) If you right click on the player the (flash player) context menu appears and the stream starts loading in the background.
So I tried to mimik that behaviour without to call a (ugly) context menu.
SendMessage/ControlClick/ControlSend/... :cry: (to trigger the context menus 'Play' option?)

During that testing I've set/used a message box.
Guess what?

2) Calling a timed msgbox right after using IE_LoadURL, removed the focus from the GUI, and the stream started loading in the background. Yeah!

But now I have an one and only ugly msgbox to get rid off. :shock:

Code:
GoSub, GuiStart

Gui, +LastFound +Resize
Gui, Show, w242 h220 Center, WebBrowser
hWnd := WinExist()

CLSID_WebBrowser := "{8856F961-340A-11D0-A96B-00C04FD705A2}"
IID_IWebBrowser2 := "{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}"
pwb := CreateObject(CLSID_WebBrowser, IID_IWebBrowser2)

AtlAxAttachControl(pwb, hWnd)

IE_LoadURL(pwb, "http://www.last.fm/widgets/popup/?url=artist%2FJustin%2520Timberlake%2Fsimilarartists&colour=grey&size=regular&autostart=1&from=popup&widget=radio")
MsgBox,,Test,,10
Return

GuiStart:
AtlAxWinInit()
CoInitialize()
Return

GuiClose:
WebTerminate:
Release(pwb)
CoUninitialize()
AtlAxWinTerm()
ExitApp

Thx for your effort, and any additional help you can provide. Much appreciated. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 8:37 pm 
Correction: Missed to add these lines at the heading section of the above script:
Code:
  #Include %A_ScriptDir%\CoHelper.ahk
  #Include %A_ScriptDir%\IEControl.ahk
:oops:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 9:00 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 969
Location: Frisia
Code:
  ; ;-)
  #Include %A_ScriptDir%\CoHelper.ahk
  #Include %A_ScriptDir%\IEControl.ahk

  ; AtlAxWinInit() is not needed (afaik)
  ;GoSub, GuiStart
  CoInitialize()

  Gui, +LastFound +Resize
  hWnd := WinExist()

  ; You don't need this anymore
  /*
  CLSID_WebBrowser := "{8856F961-340A-11D0-A96B-00C04FD705A2}"
  IID_IWebBrowser2 := "{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}"
  pwb := CreateObject(CLSID_WebBrowser, IID_IWebBrowser2)

  AtlAxAttachControl(pwb, hWnd)
  */

  winW = 242
  winH = 220

  ; handle to the IE control
  hIEC := IE_Add(hWnd, 0, 0, winW, winH)

  Gui, Show, w%winW% h%winH% Center, WebBrowser

  IE_LoadURL(hIEC, "http://www.last.fm/widgets/popup/?url=artist%2FJustin%2520Timberlake%2Fsimilarartists&colour=grey&size=regular&autostart=1&from=popup&widget=radio")
  ;MsgBox,,Test,,10 ; should run without this
Return ; End of AutoExecute section

/*
GuiStart:
  ;AtlAxWinInit() ; This you don't need anymore either (afaik)
  ;CoInitialize() ; moved to auto-execute section (top) of the script
Return
*/

GuiClose:
  WebTerminate:
  Gui Destroy ; this you need, to prevent crashes
  Release(hIEC)
  CoUninitialize()
  ;AtlAxWinTerm() ; not needed (afaik)
ExitApp

^!r::Reload ; for debugging


Hope this helps...

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2007, 9:06 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 969
Location: Frisia
Code:
GuiClose:
  WebTerminate:
  Gui Destroy ; this you need, to prevent crashes
  Release(hIEC)
  CoUninitialize()
  ;AtlAxWinTerm() ; not needed (afaik)
ExitApp


I'm still not quite sure what is needed, and what not, to do a clean init, and a clean cleanup. Apparently you only need an IE_Add() to make it work, but still need the cleanup routine to close gracefully.

It would be useful if IEControl.ahk had an IE_Cleanup() function. Maybe Sean could shed a light on this.

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2007, 4:12 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
FYI, it's loading and auto-starting fine here.
XPSP2
IE: 7.00.6000.16512
Flash: 9.0.47.0

Code:
#Include IEControl.ahk

GoSub, GuiOpen
Gui, +LastFound
Gui, Show, w800 h600 Center, WebBrowser
hWnd := WinExist()
pwb  := ActiveXObject("Shell.Explorer")
AtlAxAttachControl(pwb, hWnd)
; IE_LoadURL(pwb, "...")
Invoke(pwb, "Navigate", "http://www.last.fm/widgets/popup/?url=artist`%2FJustin`%2520Timberlake`%2Fsimilarartists&colour=red&size=regular&autostart=1&from=popup&widget=radio&resize=0&height=240&width=234&resizable=no&scrollbars=no")
Return

GuiOpen:
CoInitialize()
AtlAxWinInit()
Return
GuiClose:
Gui, Destroy
Release(pwb)
AtlAxWinTerm()
CoUninitialize()
ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2007, 2:08 pm 
Thx Sean,
I've still the same issue, which I guess is based on a local IE restriction/policy which I can't change as I don't have the permissions to check it out. :x

On the other hand, its working fine if triggered manually, thats's weird !

Slightly out of topic, my recomendation of: [Zanmantou], a JavaScript enabled, skinnable MP3/Video Flashplayer which might be of interest for daonlyfreeze and PhiLho (english short description at the lower part of that thread). 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2007, 10:35 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Do you want to play a flash SWF file?

Code:
#Include IEControl.ahk

sFile := "...\temp.swf"   ; Specify a real path to the swf file

GoSub, GuiOpen
Gui, +LastFound
Gui, Show, w800 h600 Center, WebBrowser
hWnd := WinExist()
psf  := ActiveXObject("ShockwaveFlash.ShockwaveFlash")
AtlAxAttachControl(psf, hWnd)
Invoke(psf, "Movie=", sFile)
Invoke(psf, "Play")
Return

GuiOpen:
CoInitialize()
AtlAxWinInit()
Return
GuiClose:
Gui, Destroy
Release(psf)
AtlAxWinTerm()
CoUninitialize()
ExitApp


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, robotkoer, specter333 and 68 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group