Author Topic: iTunes get/set volume?  (Read 2620 times)

0 Members and 1 Guest are viewing this topic.

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
iTunes get/set volume?
« on: June 15, 2015, 02:59:38 AM »
I'm having a tough time wrapping my head around the best practices of how to use these commands to trigger a volume change.  I'm building a mini webplayer with roboB & webserver plugins.  Right now i have the vol buttons mapped to forward the commands to EventGhost.  Using the raise vol by percentage macro.  Ideally that's what i'd like to do in VC.  Could someone post an example of how you use the iTunes get/set vol actions?

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: iTunes get/set volume?
« Reply #1 on: June 15, 2015, 05:33:22 AM »

The VC basic iTunes installation contain a "set Volume" command, so I'm not really sure for what you looking for, but this command raise or lower the iTunes volume in percent from the current volume.The command use python math, so you must first enable the python plugin in VC before you can use the command below.
Copy and paste the command in your iTunes command group and try it - have fun ;) 


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.8-->
<command id="18" name="raise/lower Volume in % from current" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>iTunes.GetVolume</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>iTunesCurrentVol1</param>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result={Var.iTunesCurrentVol1}*{1}/100</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>{LastResult}&amp;&amp;1</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>1</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{LastSpoken}&amp;&amp;lower</ifParams>
    <then>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>result={Var.iTunesCurrentVol1}-{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>result={Var.iTunesCurrentVol1}+{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>100&amp;&amp;{LastResult}</ifParams>
    <then>
      <action>
        <cmdType>Results.SetLastResult</cmdType>
        <params>
          <param>100</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>Volume has reached the highest level.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>{LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <action>
    <cmdType>iTunes.SetVolume</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>raise, lower</phrase>
  <phrase>volume</phrase>
  <payloadList>0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100</payloadList>
  <phrase optional="true">percent</phrase>
</command>
***********  get excited and make things  **********

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
Re: iTunes get/set volume?
« Reply #2 on: June 15, 2015, 08:10:45 AM »
Thank you, that was precisely what i was looking for.  Python seemed like the logical choice, just wasn't sure if there was an easier way i was missing(i'm kinda new to VC).  The screenshot below is the mini player for better explanation.  I don't have a volume slider setup.  So I wan't it to step up the volume by 10% with each click.  Again, thank you.

« Last Edit: June 15, 2015, 08:17:12 AM by yokel »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: iTunes get/set volume?
« Reply #3 on: June 15, 2015, 09:43:01 AM »
Nice to hear that is exact what you looking for, but in my case I would not prefer the percentage from the current level. I would prefer more for a example like: If your current volume is 23, in that case it will set the volume for each click on the button 10+/- like 33,43,53,... or 13,3,0  this makes more sense for me  :o


If you search more for this, let me know  ;)


or maybe you can figured it out by your self with my given command.
***********  get excited and make things  **********

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
Re: iTunes get/set volume?
« Reply #4 on: June 15, 2015, 09:56:31 AM »
That's exactly what i did.  It's posted here now.  http://voxcommando.com/forum/index.php?topic=2216.msg19164#msg19164