Author Topic: Discrete Pause / Play for XBMC  (Read 5268 times)

0 Members and 1 Guest are viewing this topic.

mrmagica

  • Jr. Member
  • **
  • Posts: 23
  • Karma: 0
    • View Profile
Discrete Pause / Play for XBMC
« on: August 30, 2013, 08:53:53 PM »
Going well with VC. Only issue is it won't recognise anything I'm saying when have loud music / movie on. Obviosuly not the VC.On command which almost sets the volume lower...

Decided to get round this by fitting a USB activated button and mapping it to a keypress in EventGhost. Stick the button next to the sofa and can use it to trigger VC to listen and lower the volume - excellent.

Problem: Fine for music but as I use spdif digital sound for my movies (5.1) no volume control is possible. I would totally mute the sound but that doesn't work either, just ignores spdif stream. My only idea for a work around was to Pause the media rather than mute it until command issued. Problem is XBMC and my remote only seem to use a rocker Play / Pause option, and I can't find a discreet Pause and seperate Play command for XBMC like you can usually find. Obviously this is a mess if you give the initial command when something is paused, and it actually un-pauses the media when you are trying to give a vocal command. I've looked into xbmc keyboard.xml and found a seperate listing for Play and Pause, however I have found these both seem to actually still act as rockers of Play/Pause command.

Seems ridiculous in a program like XBMC when so infinitely programmable - anyone know a way?
« Last Edit: January 29, 2015, 06:13:35 PM by nime5ter »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Discrete Pause / Play for XBMC
« Reply #1 on: August 31, 2013, 05:34:50 AM »
Hi mrmagica, you can test the following group. You must only edit the event in "pause xbmc for a single command" with the event from pause button that come from EG.

The command do following: If you press the pause button on your remote (only if this button send a event to VC) VC set XBMC to pause and goes for on single command in ON mode - after your spoken command it goes to standby and set xbmc to play.

You can drag'n drop the code directly from here in to your command tree. I hope this help or show you a way how you can solve your problem.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="xbmc pause when trigger VC" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="1136" name="pause xbmc for a single command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>Input.ExecuteAction&amp;&amp;"action":"pause"</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.OnSingle</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>pause button event from EG</event>
  </command>
  <command id="1137" name="play xbmc after command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>Input.ExecuteAction&amp;&amp;"action":"pause"</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.Single.End</event>
  </command>
</commandGroup>
« Last Edit: January 29, 2015, 06:13:48 PM by nime5ter »
***********  get excited and make things  **********

mrmagica

  • Jr. Member
  • **
  • Posts: 23
  • Karma: 0
    • View Profile
Re: Discreet Pause / Play for XBMC
« Reply #2 on: August 31, 2013, 08:00:04 AM »
Hi Kalle, thanks for your response... Also thanks for all the youtube videos on VC, have watched them a number of times to help me get familiar with VC!

The code is great, however the core problem that XMBC pause command works as a toggle, not a firm pause remains. I want to be able to Pause, and if media is playing for it to pause, if the media is already paused it should do nothing. At present the pause command will toggle that state which is not a suitable outcome.

I might try using a "stop" and "resume" command but this is not really ideal......

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Discreet Pause / Play for XBMC
« Reply #3 on: August 31, 2013, 08:22:48 AM »
Thanks, the command in the group above is only a "demo" in that I will show you we have a "On.Single" action which is perfect to use it with events. I'm sure James can tell you more about a discret command for "play" in xbmc.
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Discrete Pause / Play for XBMC
« Reply #4 on: August 31, 2013, 08:46:16 AM »
XBMC seems to offer about 12 different ways to toggle pause, but none for discrete pause and play as you say.  For all its virtues, XBMC is often quite baffling.

My first suggestion would be to mute / unmute your audio receiver, but that is probably not an option for you.

What you might need to do is to check if XBMC is playing or not and then act accordingly.  I will need to look into this a bit.  The ideal solution would probably involve adding a new method to voxtools, but it should also be possible to do it all in VC using existing tools.
« Last Edit: January 29, 2015, 06:14:10 PM by nime5ter »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Discrete Pause / Play for XBMC
« Reply #5 on: August 31, 2013, 11:07:52 AM »
OK, I found lots of ways to handle this.  I will not go into the more advanced methods (until a later post) of detecting whether xbmc is playing video, audio, or nothing, and if playing video then check to see if it is paused.

In the meantime, here is a sneaky way to force a discrete pause / unpause.

I say unpause because it is not going to act as play, unless something is already playing, but is paused.

In XBMC all the buttons and execute-actions for play, pause, play/pause do the same thing, as you have noted, which is to toggle play and pause.

What is even more ridiculous is that we have a json method: player.setspeed, and if you use this to set the speed to 0 you would think it would always cause XBMC to pause.  But alas, if XBMC is already paused, setting the speed to 0 will cause it to start playing again!  This is, of course, ridiculous but I found a way around it.

Setting the play speed to 2 will always set it to 2, even if it is already at 2.  So, in order to

Pause:  set play speed to 2, then set it to 0
Play: set play speed to 2, then set it to 1

This does result in a slight playback "blip" if you are paused and you re-pause, but it seems to work OK.  Alternatively you could try using a play speed of -1 instead of 2.


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="xbmc sneaky video pause unpause" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="1141" name="cheating video pause" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>player.setspeed&amp;&amp;"playerid":1,"speed":2</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>player.setspeed&amp;&amp;"playerid":1,"speed":0</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="1147" name="cheating video unpause" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>player.setspeed&amp;&amp;"playerid":1,"speed":2</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>XJson.Raw</cmdType>
      <cmdString>player.setspeed&amp;&amp;"playerid":1,"speed":1</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
</commandGroup>
« Last Edit: August 31, 2013, 12:55:28 PM by jitterjames »

mrmagica

  • Jr. Member
  • **
  • Posts: 23
  • Karma: 0
    • View Profile
Re: Discreet Pause / Play for XBMC
« Reply #6 on: August 31, 2013, 11:40:57 AM »
amazed you can find a clver work around for this stuff so quickly! Seems ridiculous that even setting the pay speed to 0 could actually result in a play state! While a small issue think a dev at xbmc needs to address this. In macros this discrete codes are often vital. I have hidden discreets for my old projector, amplifiers from 8 years ago so it's amazing that xbmc hasn't!

Thanks james! If anyones interested I will be triggering this command with a big USB push button on the wall or coffee table. Gives an option to issue commands when things are loud, without looking stupid shouting at a microphone with no response.....

Something like one of these "smart USB buttons". They trigger websites for ads, but can be reprogrammed to issue a keypress picked up by EG....


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Discreet Pause / Play for XBMC
« Reply #7 on: August 31, 2013, 01:22:39 PM »
Cool button.  Were you able to buy it like that, and if so, how much $$$.

Or did you need to mod it yourself?

mrmagica

  • Jr. Member
  • **
  • Posts: 23
  • Karma: 0
    • View Profile
Re: Discreet Pause / Play for XBMC
« Reply #8 on: August 31, 2013, 05:19:10 PM »
Haven't actually ordered one yet, just finding the right one.

For a heads up, I found these last night. There usually known as Smart USB Buttons. There usually brought by companies in hundreds and given out free. If you plug them into a PC they run a macro, for example loading a webpage through simple shortcut keypresses. To mod one you need an EEPROM wire and some freeware software to run another keystroke (they work like a USB keyboard).

Another one I might order (cost £4 in the UK on ebay) is an eco button. Same thing, however they run a .bat file which puts the computer into hibernate mode. It does this by typing <windows ket +r> then typing eco button <return>.

If you just change the bat file you can have it do anything you want without need to reprogram anything, however im guessing pressing windows + r might interrupt XBMC.. Maybe you can tell me james what would be the easest way to issue a command to EG or VC from a batfile if I go that route?

Here are some links if anyone wants to look into it:

http://www.usbsmartbuttons.com/

http://hardforum.com/showthread.php?t=1312818

http://www.instructables.com/id/Hack-your-Ecobutton/