View Full Version : Browser plugin - How do I...
NeoMorph
July 20th, 2007, 01:52 AM
I want to use a NR button to open a url on my xbox. It generates a keypress in the xbox to simulate a joypad.
OK... I've tried just putting a Go to URL event in (WEB1,http://xbox/xbmcCmds/xbmcHttp?command=SendKey¶meter=256) and added a refresh after it as it doesn't seem to work right else but it's behaving erratically.
I'm an obvious n00b here and can't see what I'm doing wrong. If I put the url into IE it works the first time but I have to refresh to page to send subsequent keypress simulations of the A button.
tmorten
July 20th, 2007, 11:27 AM
In my CCF, I've noticed that the browser window doesn't seem to actually jump to a page unless it's on-screen... is it hidden while you're trying to do this?
NeoMorph
July 20th, 2007, 03:30 PM
Nope... not hidden.
I have managed to simulate manually what I want to do in IE. Here is the sequence I need to do (I know it's not syntactically correct but I don't know lua).
// nURL is the new URL
// oURL is the old URL
If (nURL == oURL) {
Refresh Webbrowser
} Else {
oURL = nURL
Load nURL in Webbrowser plugin
}
I know this is possible but I just haven't got a clue where lua is concerned. I really need some examples to look at.
tmorten
July 20th, 2007, 03:49 PM
Is it not responding at all, or just responding erratically?
It sounds like you're doing something like this?
-- If the address is the same as before then
if ( szAddress == szLastAddress) then
-- Jump to the current page to force a refresh
NetRemote.GoDevice( "Device", "Page" );
-- Otherwise
else
-- Send the browser to the new address
NetRemote.ExecuteAction( -2, 1, 32, 'Web,'..szAddress );
end;
NeoMorph
July 20th, 2007, 04:05 PM
I posted the changes to my previous post just before you sent the latest suggestion.
Ok... here is a URL that I want to call...
WEB1,http://xbox/xbmcCmds/xbmcHttp?command=SendKey¶meter=257
... that's ok for the first time... if I need to do it a second time I need to refresh WEB1.
I'm sorry if I sound thick but it's because I have to take morphine for pain and it kind of dulls the brain. I used to be a professional programmer on mainframes and knew loads of languages but nowadays it's really hard to grasp (and remember) new languages. :(
NeoMorph
July 20th, 2007, 04:32 PM
Oh this is doing my head in... A webpage with the following works fine...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</head>
<body>
<blockquote>
<h5 align="center">
<a href="index.html" target="_top">< Back</a><br/>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=256" target="topFrame">A</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=257" target="topFrame">B</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=258" target="topFrame">X</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=256" target="topFrame">Y</a><br/>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=270" target="topFrame">#</a><br/>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=272" target="topFrame">#</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=256" target="topFrame">ok</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=273" target="topFrame">#</a><br/>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=271" target="topFrame">#</a><br/>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=274" target="topFrame">Start</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=275" target="topFrame">Back</a><br/>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=261" target="topFrame">White</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=260" target="topFrame">Black</a><br />
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=276" target="topFrame">Lthumb</a>
<a href="/xbmcCmds/xbmcHttp?command=SendKey&parameter=277" target="topFrame">Rthumb</a></h5>
</blockquote>
</body>
</html>
... and it responds correctly. It even works fine in the NR browser object. All I want to do is use NR's graphic front end to make it look cleaner but it behaves really weird!
tmorten
July 20th, 2007, 05:09 PM
What behavior are you seeing? Hopefully I can help...
Also, do you use Girder in addition to NetRemote? You could potentially hide each command behind a button, which would trigger a Grider event, which would take care of the request under the covers on the Girder side (without a browser window running in NetRemote).
Best,
Tim
NeoMorph
July 20th, 2007, 08:42 PM
I've figured out how to show a good example of the problems I'm having with a simple CCF that I've attached to this post.
The CCF links to 3 web pages which are identical and just show the time. Clicking between the different buttons take you to time1.php, time2.php and time3.php that are located at http://www.neomorph.net/timetest/.
The problem is that the web page doesn't update correctly. When you go from time1.php to time2.php and then back to time1.php you find that the page doesn't update and the time stays the same. It only updates if you do a refresh.
Is this the cache overriding the page update?
tmorten
July 20th, 2007, 11:08 PM
I believe a previously browsed page won't refresh unless you explicitly refresh it or jump to the page (from itself or from another page). Your example CCF seems to bear this out... I added a refresh action after the URL request in the action list for each of the buttons, and this caused them to update to a new value on each press.
Cheers,
Tim
NeoMorph
July 21st, 2007, 12:09 AM
Darn... I knew I should have made the three php pages look different.
There is a weird effect if you do it your way... it doesn't refresh the page you have just jumped to but actually jumps to the page it was on previous again. I suppose you could add a delay but to allow the url to update but if it doesn't get to the url before the page is displayed it goes back again.
It was this that was causing inconsistent results.
OK... so now I've actually got that lua of yours sort of working.
szAddress="http://192.168.0.177/xbmcCmds/xbmcHttp?command=SendKey¶meter=256"
if ( szAddress == szLastAddress) then
NetRemote.ExecuteAction( -2, 1, 17,'WEB1');
else
NetRemote.ExecuteAction( -2, 1, 32, 'WEB1,'..szAddress );
szLastAddress=szAddress;
end;
The only problem is when you change buttons... the first button press isnt responding yet every consecutive one works fine.
You are right that the web page needs to update but putting a refresh after the url doesn't work. I just refreshes the previous page. Even stranger is that the second time through the script it actually DOES do a correct refresh. Does NR release the web browser which means the next time through it refreshes correctly wheras the first time through the web page hasn't actually registered in the browser which is why the refresh done then refreshes the wrong page?
I'm starting to think it's not a bug on my side now but a bug in the way that the browser plugin works. :(
NeoMorph
July 21st, 2007, 01:56 AM
I believe a previously browsed page won't refresh unless you explicitly refresh it or jump to the page (from itself or from another page). Your example CCF seems to bear this out... I added a refresh action after the URL request in the action list for each of the buttons, and this caused them to update to a new value on each press.
Cheers,
Tim
Here you go Tim... I've added the refresh after each URL call and changed the web pages so that you can see which one is being called.
It then starts going pear shaped when you try calling Time1 then Time2... when you hit Time2 it still calls up Time1 instead... the same happens with Time3.
OK... now restart NR... now click Time3 a couple of times instead... then click Time1... oops... now it's stuck on Time3 instead.
Something is definately screwy. Can anyone from Proxmis give any suggestions here?
tmorten
July 21st, 2007, 10:38 AM
There may indeed be a bug with the refresh -- that said, if you replace your refresh actions with jumps to the page, this seems to correctly cause a refresh.
Best,
Tim
tmorten
July 21st, 2007, 10:40 AM
Here's the modified version of your example...
NeoMorph
July 21st, 2007, 12:15 PM
I thought it worked and was all ready to celebrate...
Try this... hit the same button twice quickly... second time it gets ignored so it ends up going "worked... ignored... worked... ignored" etc.
How do you do a jump call in lua. I think if I used the jump after the first url entry (when in fails for the first time in my code but works using a jump) the refresh code I already have would take over and work fine after that. It's just the first button press that is failing in the lua code.
NeoMorph
July 21st, 2007, 12:45 PM
NetRemote.GoDevice('HOME','XBMC');
I've tried using the above lua code to jump to the XBMC page but it keeps throwing up a dialog saying "Didn't find device".
I'm rather confused here. :(
Well it looks like it isn't just me - see here... http://www.promixis.com/forums/showthread.php?t=16926
tmorten
July 21st, 2007, 12:59 PM
Home pages are a special case... if the XBMC page is under the "Home" section, use:
NetRemote.GoHome( "XBMC" )
NeoMorph
July 21st, 2007, 01:23 PM
szAddress="http://192.168.0.177/xbmcCmds/xbmcHttp?command=SendKey¶meter=256";
if ( szAddress == szLastAddress) then
NetRemote.ExecuteAction( -2, 1, 17,'WEB1');
else
NetRemote.ExecuteAction( -2, 1, 32, 'WEB1,'..szAddress );
szLastAddress=szAddress;
NetRemote.GoHome("XBMC");
end;
OK that's the code I TRIED to use to get this workaround working... It mostly works but the line where you have NetRemote.GoHome("XBMC"); causes netremote to crash. If you use NetRemote.GoDevice("PageGroup1","XBMC"); it throws up the "Device not found" error dialog.
Looks like this simple problem is being a right pain in the bum... All I want it to do is jump to the XBMC page now and I can't get it to work.
tmorten
July 21st, 2007, 02:22 PM
Hmm... sorry to hear that you're crashing -- I use GoHome and GoDevice extensively in my CCF, and haven't had any issues. In NetRemote Designer, is the "XBMC" page under "Home" or is it under another named device?
Also, where is the LUA residing/being called from?
NeoMorph
July 21st, 2007, 11:11 PM
Hmm I think I didn't submit my long last post and previewed it instead and then closed the browser. DOH!
The lua in attached to each button under "Execute lua on (DownPress)". I've tried renaming the pagegroup from HOME to PAGEGROUP1 and calling...
NetRemote.GoDevice('PAGEGROUP1','XBMC'); but it still throws out a "Device not found" window with the window title set as "PAGEGROUP1".
I haven't done any more attempts as I though a change was as good as a rest and went over to update my XBOXes media center software (at least that went well and have got them working just how I want them now). I'll have another attempt at the jump problem later today.
tmorten
July 21st, 2007, 11:33 PM
Odd... not knowing the NR internals, but knowing that these calls work in my CCF, it seems like the problem should be one of the following:
Case sensitivity - don't know if it applies - or just a typo causing a mismatch. Make sure the names match exactly what is indicated in NetRemote Designer.
Perhaps a page group that was once named home retains a home property even after it's been renamed (this would be a bug if it were the case). You could try creating an all-new page group.
I make my calls from a function within the .LUA file associated with the .CCF; this should behave identically to LUA within the CCF itself, but I suppose it's always possible that there's some difference in behavior (which would again seem to imply a bug). If all else fails, try externalizing your LUA and see if the behavior changes.
Let me know if any of those help...
Best,
Tim
NeoMorph
July 21st, 2007, 11:42 PM
OK... that device not found has gotta be a NR bug...
Although I have the error dialog pop up the command has gone through and the xbox actually responds corrects... every... darned... time. No ignored button pushes at all... if the dialog was to go away it would be working perfectly. I've even figured out how to stop the spurious last command being re-issued when I return to the XBMC remote page. I just set a blank page content to the browser before I jumped to the home page.
Bugs... the bane of a programmers life.
Rob H
July 22nd, 2007, 03:02 AM
Try adding a false parameter to the NetRemote.GoDevice() call, that should suppress the dialog.
tmorten
July 22nd, 2007, 08:49 AM
Also, if it's easy to post a sample CCF that exhibits the error, I'd be keen to figure out the source of it.
Best,
Tim
NeoMorph
July 22nd, 2007, 01:11 PM
Try adding a false parameter to the NetRemote.GoDevice() call, that should suppress the dialog.
Where in the call do I insert the false parameter Rob? I'm pretty much learning as I go at the moment.
Tim, I dunno if it would help to have my example as you need an XBOX running XBMC to see it in action. I'll knock up a demo php page later on and create a demo for you to see what's happening. Rob's comment seems to point to a bug in GoDevice at the present time.
NeoMorph
July 22nd, 2007, 05:12 PM
That GoDevice command is well and truly bugged. I tried to see if I could retrieve the page group and name and then forward them to GoDevice...
g = NetRemote.GetCurrentPageGroup();
gn = g:GetName();
print('++Pagegroup++');
print(gn);
print('--Pagename--');
p = NetRemote.GetCurrentPage();
pn = p:GetName();
print('++Pagegroup++');
print(pn);
print('--Pagename--');
NetRemote.GoDevice(gn,pn);
Ding... No luck still.... "Can't find Device" and another thing... I was wrong in thinking that it actually worked other than the error message. It doesn't do anything at all. :(
Until Rob H can expand on that "add a dummy parameter" suggestion I'm stuck.
tmorten
July 22nd, 2007, 05:43 PM
Am I correct that GoDevice is returning an error for you 100% of the time? If so, can you send me a CCF to give it a try on my end (even if the pages don't come up, as long as it generates the device not found error)? I may be able to give you a companion LUA file that will do the trick...
NeoMorph
July 22nd, 2007, 06:04 PM
Am I correct that GoDevice is returning an error for you 100% of the time? If so, can you send me a CCF to give it a try on my end (even if the pages don't come up, as long as it generates the device not found error)? I may be able to give you a companion LUA file that will do the trick...
Here you go...
One thing... In my XBMC version I replaced GoDevice with GoHome and it does crash NR on my PC... but strangely enough not on my PPC. Go figure :?
I've included a button that crashes netremote on my pc but not on my ppc to demonstrate.
Tim, if I've not said this before, thanks a lot for all your help... it's well appreciated.
Rob H
July 23rd, 2007, 02:28 AM
The extra parameter goes at the end e.g.
NetRemote.GoDevice('GROUP', 'PAGE', false)
NeoMorph
July 23rd, 2007, 07:47 AM
I tried your code Rob and it does stop the error message... but it doesn't do the jump command either. If it's in another page group it works but then crashes NetRemote like GoHome does (but only on a PC. On a PPC it works fine... is it a bug in NR PC version?
On furthur examination the following:-
NetRemote.GoDevice('HOME','Page1',false);actually shows this in the lua console
Loading group HOME and page Home
Loaded group HOME and page Home
Oops!
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.