|
|
|
The following page was printed from RemoteCentral.com:
Question on simple toggle script
| |
|
Topic: | Question on simple toggle script This thread has 14 replies. Displaying all posts. |
|
Post 1 made on Thursday August 26, 2010 at 05:45 |
miwi Long Time Member |
Joined: Posts: | December 2004 34 |
|
|
Hello experts,
I try to have a simple toggle script for Play and Pause action on the same button.
Means my Bluray player has Pause and Play separated and there is no Play/Pause toggle IR code.
Therefor I want to put both IR codes on the same button and use it as ping/pong.
When entering the page I would like to have the related button showing the "Pause" symbol. As soon as I execute this button it should send the Pause IR code and then switch this button to "Play" including changing the symbol. If I then execute this new play button it should execute the Play IR code and switch then back to the initial pause function.
The code I used / found related to that is made power tracking which I do not need as I do not need to track actual status.
Code is:
var pwrOn = System.getGlobal("PSG_PWRON"); if ( pwrOn == null ) { pwrOn = "On"; } if ( pwrOn == "On" ) { CF.widget("Play", "HIDE", "DVDBEAMER").executeActions(); pwrOn = "Off"; } else { CF.widget("Pause", "HIDE", "DVDBEAMER").executeActions(); pwrOn = "On"; }; System.setGlobal("PSG_PWRON", pwrOn);
Thanks for helping me and sorry for asking such simple things...
miwi
|
Miwi |
|
Post 2 made on Thursday August 26, 2010 at 07:44 |
Lowpro Select Member |
Joined: Posts: | March 2004 2,081 |
|
|
In the below example Firm5 is being used versus an on-screen button. Place the below at the activity level:function doPageStart() { if(System.getGlobal("Blu-ray Play/Pause")=="Play") { GUI.widget("PS_FIRM5").label="Play \uF087"; } else { System.setGlobal("Blu-ray Play/Pause","Pause"); GUI.widget("PS_FIRM5").label="Pause \uF085"; } } // function bdPlayPause() { if(System.getGlobal("Blu-ray Play/Pause")=="Play") { CF.widget("Play","Blu-ray","IR Codes").executeActions(); System.setGlobal("Blu-ray Play/Pause","Pause"); GUI.widget("PS_FIRM5").label="Pause \uF085"; } else { CF.widget("Pause","Blu-ray","IR Codes").executeActions(); System.setGlobal("Blu-ray Play/Pause","Play"); GUI.widget("PS_FIRM5").label="Play \uF087"; } }Place the below at the page level:doPageStart();Place the below on Firm5:bdPlayPause();Note that I'm using both text and the appropriate symbol when addressing the label of the firm key. See Appendix C of the "ProntoScript Developer's Guide" for a full listing of the special unicode characters which are available. Note also that while a regular variable would work per the above I've chosen to use a global variable instead, that way if one leaves the activity then returns to the activity the "Play/Pause" functionality is still set to the proper state. Getting things back in sync...In the event the true "Play/Pause" state of your Blu-ray player gets out of sync with the remote it's always good to have a quick and easy way to get things back in sync via the remote. The below ProntoScript adds "Press & Hold" functionality to the firm key. A normal press of the firm key will execute the "Play/Pause" functionality. An extended press of the firm key will change the naming of the label only in addition to updating the global variable allowing you to easily get things back in sync if needed. Add the below at the activity level:function bdPlayPauseSync() { if(System.getGlobal("Blu-ray Play/Pause")=="Play") { System.setGlobal("Blu-ray Play/Pause","Pause"); GUI.widget("PS_FIRM5").label="Pause \uF085"; } else { System.setGlobal("Blu-ray Play/Pause","Play"); GUI.widget("PS_FIRM5").label="Play \uF087"; } }Place the below on Firm5: var counter = 0; onHold = function() { counter++; if (counter==1) { bdPlayPauseSync(); } } onHoldInterval = 1000; onRelease = function() { if (counter==0) { bdPlayPause(); } }
Last edited by Lowpro on August 26, 2010 17:40.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
Post 3 made on Thursday August 26, 2010 at 07:46 |
BluPhenix Long Time Member |
Joined: Posts: | December 2008 371 |
|
|
Simpler approach: have 2 buttons one over another one with the play and the other with the pause symbol, one tagged "PLAY", the other "PAUSE" each with it's ir code.
You can do it like this:
var play = widget("PLAY"), pause = widget("PAUSE");
pause.visible = false; play.visible = true;
play.onRelease = function () { play.visible = false; pause.visible = true; this.scheduleActions(); }
pause.onRelease = function () { pause.visible = false; play.visible = true; this.scheduleActions(); }
You'll get two alternating buttons each with it's IR codes. Hope it helps.
|
|
OP | Post 4 made on Thursday August 26, 2010 at 07:55 |
miwi Long Time Member |
Joined: Posts: | December 2004 34 |
|
|
Thanks for the solutions.
I will try to understand the commands.
BluPhenix,
Is your solution also possible with the graphics of Firmkeys ?
Thanks,
miwi
|
Miwi |
|
Post 5 made on Thursday August 26, 2010 at 08:03 |
Lowpro Select Member |
Joined: Posts: | March 2004 2,081 |
|
|
The example I provided does utilize the firm keys. See post 2 above. The example BluPhenix provided will not work on a firm key, only with on-screen buttons.
Last edited by Lowpro on August 26, 2010 09:32.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
OP | Post 6 made on Thursday August 26, 2010 at 08:24 |
miwi Long Time Member |
Joined: Posts: | December 2004 34 |
|
|
Hi Lowpro,
your sollution is working well.
1 more little thing to make it perfect:
The panel/softbutton that belongs to the firmkey is empty when entering the page. Only after 1st press the toggle text "Play" and "Pause" appears.
Thanks
miwi
|
Miwi |
|
Post 7 made on Thursday August 26, 2010 at 08:54 |
Lowpro Select Member |
Joined: Posts: | March 2004 2,081 |
|
|
I've updated my earlier reply, post 2. That should do the trick.
Last edited by Lowpro on August 26, 2010 09:11.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
OP | Post 8 made on Thursday August 26, 2010 at 09:21 |
miwi Long Time Member |
Joined: Posts: | December 2004 34 |
|
|
YYYYEEEEESSSS !!!!
That exact what I want the Key to do.
Thanks Lowpro for your help !!!
miwi
|
Miwi |
|
Post 9 made on Thursday August 26, 2010 at 10:15 |
Lowpro Select Member |
Joined: Posts: | March 2004 2,081 |
|
|
On August 26, 2010 at 09:21, miwi said...
YYYYEEEEESSSS !!!!
That exact what I want the Key to do.
Thanks Lowpro for your help !!!
miwi You're welcome! I've updated my prior reply (Post 2) by the way. Check it out. I've added "Press & Hold" functionality to the firm key providing for a quick and easy way to get the remote back in sync with the true "Play/Pause" state of your Blu-ray player if needed.
|
LP Related Links: View my profile to access various links to key posts and downloads. |
|
Post 10 made on Wednesday May 30, 2012 at 17:34 |
Sorry for reviving an old thread but would love to do this exact same thing with my Blu-Ray player and going through the developer guide did not help.
Right now I have:
Activity "RF Devices" that contains Page "Blu-ray" that contains the two tagged widget/button Play and Pause.
I added what is required as per LP post #2 but taking into account the above and Firmkey 1 for the activity script:
function doPageStart() { if(System.getGlobal("Blu-ray Play/Pause")=="Play") { GUI.widget("PS_FIRM1").label="Play \uF087"; } else { System.setGlobal("Blu-ray Play/Pause","Pause"); GUI.widget("PS_FIRM1").label="Pause \uF085"; } } // function bdPlayPause() { if(System.getGlobal("Blu-ray Play/Pause")=="Play") { CF.widget("Play","Blu-ray","RF Devices").executeActions(); System.setGlobal("Blu-ray Play/Pause","Pause"); GUI.widget("PS_FIRM1").label="Pause \uF085"; } else { CF.widget("Pause","Blu-ray","RF Devices").executeActions(); System.setGlobal("Blu-ray Play/Pause","Play"); GUI.widget("PS_FIRM1").label="Play \uF087"; } }
Now I'm getting the following error from the console:
ProntoScript error: ActionList Error Offending activity script: Tag: 'Blu-ray' Offending line #17: "CF.widget("Pause","Blu-ray","RF Devices").executeActions();"
Any ideas how I can solve this?
Thanks,
Martin
|
|
Post 11 made on Wednesday May 30, 2012 at 18:09 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
In PEP2/3, have you enabled the advanced mode and made sure that the ProntoScript name, and not the label (the label for pages and activities is what displays in the tree view) has been properly setup?
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
Post 12 made on Wednesday May 30, 2012 at 19:48 |
Yes, PEP3, Advanced Mode enabled and ProntoScript names tripple checked.
Thanks for the suggestions Lyndel,
Martin
|
|
Post 13 made on Wednesday May 30, 2012 at 21:28 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
Ahhhh. I bet I know what the issue is. Someone reported something similar to me via email earlier this week. Are extenders in use for your project? Are you using Jon Welfringer's simulator patch? Without this patch to allow sim to talk to real extender, you will likely get ActionList errors and Page Text will say "Connection Failed" when you try to execute an action intended for the extender in the Simulator. In order to simulate without Jon's patch, you should remove the extender fro the component. Finally, when you download this to the real remote (with the extender activated for the component), do you have the same issue? If you want to email me to config, please do so and I'll have a look.
Last edited by Lyndel McGee on May 30, 2012 21:36.
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
Post 14 made on Thursday May 31, 2012 at 05:14 |
Lyndel, you're a genius! Yep, downloaded to the remote and it works just fine!
I do have a RFX9400 extender (standalone mode) in my configuration and did not change to IR but also have an "Admin" page that allows me to jump directly to the Blu-ray page without going through the start up macro. Wrongly thought that I would be able to use the simulator by selecting my "Admin" shortcut to see the result...
Thanks again,
Martin
|
|
Post 15 made on Thursday May 31, 2012 at 18:53 |
Lyndel McGee RC Moderator |
Joined: Posts: | August 2001 12,999 |
|
|
Just call me "Karnak The Magnificent"
"Heeeere's Johnny"
|
Lyndel McGee Philips Pronto Addict/Beta Tester
|
|
|
Before you can reply to a message... |
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now. |
Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.
|
|