[MAC] Volume Level Control

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
winestock Offline
Fan
Posts: 396
Joined: Jan 2011
Reputation: 4
Post: #1
Hi,

I am using the Apple remote to control the XBMC menus and play videos. I have noticed that when I turn up the volume using the + and - buttons, on the remote, the volume only seems to control the internal XBMC volume level and not the OS volume level. Is there a way to change the behavior so that changing the volume through the remote will change the OS volume level instead of the XBMC volume level? I have searched the forums but found no answer.

Any help would be appreciated.

OSX Version 10.6.6
Platform 2008 24" 3.06GHz iMac with 4GB RAM
Install Method dmg
SVN Revision 35648
Skin Transparency!
(This post was last modified: 2011-02-05 06:42 by winestock.)
find quote
snowdrift Offline
Senior Member
Posts: 213
Joined: Aug 2009
Reputation: 0
Post: #2
I don't think there's a way to do it through XBMC, but I use Remote Buddy and have a key on the remote mapped (using remote buddy) to bring up the Remote Buddy menu. You can then do it through there.
find quote
winestock Offline
Fan
Posts: 396
Joined: Jan 2011
Reputation: 4
Post: #3
Snowdrift,

I was unsure thanks for confirming it for me. I am working on a possibility that would allow XBMC to control the OS volume level. Unfortunately, I am stuck on the solution until I can figure out why System.Exec is not working from within keymap.xml. I have started a topic on this: http://forum.xbmc.org/showthread.php?tid=92506.
(This post was last modified: 2011-01-31 05:26 by winestock.)
find quote
snowdrift Offline
Senior Member
Posts: 213
Joined: Aug 2009
Reputation: 0
Post: #4
winestock Wrote:Snowdrift,

I was unsure thats for confirming it for me. I am working on a possibility that would allow XBMC to control thr OS volume level. Unfortunately, I am stuck on the solution until I can figure out why System.Exec is not working from within keymap.xml. I have started a topic on this: http://forum.xbmc.org/showthread.php?tid=92506.

Cool. I will watch that thread with interest. Incidentally, have you tried the command to System.Exec without the quotes?
find quote
winestock Offline
Fan
Posts: 396
Joined: Jan 2011
Reputation: 4
Post: #5
Snowdrift,

I have tired calling System.Exec with and without quotes both resulting in the same issue, non-execution of the shell script. I know the keymap.xml is working because when I replace the System.Exec call with VolumeUp the volume level changes for the internal XBMC volume level.
find quote
winestock Offline
Fan
Posts: 396
Joined: Jan 2011
Reputation: 4
Post: #6
I did some looking around and found a good work around to allow me to control the OS volume level from my Apple remote. At first I wanted to use the built-in function System.Exec but for some reason I could never get it to work in userdata/keymaps/keymap.xml. I opened a bug report on this.

It was posted, in another thread, that apple scripts could be called via the RunScript command. So for those who are interested here are the changes I made to be able to control the OS volume level using the Apple Remote while XBMC was playing a movie:

userdata/keymaps/keymap.xml:
Code:
<keymap>
  <Home>
    <joystick name="AppleRemote">
      <button id="6"></button>
      <button id="8">ActivateWindow(shutdownmenu)</button>
    </joystick>
  </Home>
  <FullscreenVideo>
    <joystick name="AppleRemote">
      <button id="1">RunScript(../scripts/VolumeUp.applescript)</button>
      <button id="2">RunScript(../scripts/VolumeDown.applescript)</button>
      <button id="3">StepBack</button>
      <button id="4">StepForward</button>
      <button id="5">Pause</button>
      <button id="6">Stop</button>
      <button id="7">OSD</button>
      <button id="8">ShowVideoMenu</button>
      <button id="9">Rewind</button>
      <button id="10">FastForward</button>
      <button id="11">Rewind</button>
    </joystick>
  </FullscreenVideo>
  <VideoMenu>
    <joystick name="AppleRemote">
      <button id="5">Select</button>
      <button id="6">Stop</button>
      <button id="7">OSD</button>
      <button id="8">ShowVideoMenu</button>
    </joystick>
  </VideoMenu>
</keymap>

VolumeUp.applescript:
Code:
-- volume up 10
set current_volume to output volume of (get volume settings)

if current_volume is less than 100 then
    set current_volume to current_volume + 10
end if

set volume output volume current_volume

VolumeDown.applescript:
Code:
-- volume down 10
set current_volume to output volume of (get volume settings)

if current_volume is greater than 0 then
    set current_volume to current_volume - 10
end if

set volume output volume current_volume

A few things to note about the above files. If you noticed I used "../scripts" in keymap.xml. The nice thing about this is if you share the userdata among multiple machines, that have different users, no change is required. I place my scripts in the scripts directory that is at the same level as the keymaps directory. I also changed button ID 8 from FullScreen to ShowVideoMenu as I wanted to be able to easily access the DVD menu without having to go through the OSD menu.

The above work around seems to work really well. You don't lose the ability to change the XBMC volume level, you would now have to go through the OSD menu to change it.

One thing not included in this work around is the ability to show what the OS volume level is changing to. I would love to be able to display the volume level like OS X does with its tranparent window. I will research more and see what I can find. I did open a feature request to have a built-in capability to change the OS volume level in XBMC.
(This post was last modified: 2011-02-05 06:47 by winestock.)
find quote
winestock Offline
Fan
Posts: 396
Joined: Jan 2011
Reputation: 4
Post: #7
By the way, name the file keyboard.xml in userdata/keymaps. keymap.xml has been depreciated.

I have made a change to VolumeUp.applescript and VolumeDown.applescript so that they are more percise in how they lower and raise the OS volume level. The changes I made follow the values Apple uses.

VolumeUp.applescript:
Code:
-- List of all volume values.
set VolumeList to ¬
    {0, 6, 13, 19, 25, 32, 37, 43, 49, 56, 64, 69, 74, 82, 88, 94, 100}
set VolumeListLen to count of VolumeList

-- Get the current OS volume level.
set CurrentVolume to output volume of (get volume settings)
set VolumeIndex to 1

-- Determine what the current volume level is so that the volume
-- can be raised.
repeat with VolumeFound in VolumeList
    if VolumeFound ≥ CurrentVolume then
        exit repeat
    end if
    
    -- Did not find the current volume level so look at the next value.    
    set VolumeIndex to VolumeIndex + 1
end repeat

-- Determine what the next lower volume level will be.
if VolumeIndex < VolumeListLen then
    set VolumeIndex to VolumeIndex + 1
end if

set NextVolume to item VolumeIndex of VolumeList

-- Volume Up
set volume output volume NextVolume

VolumeDown.applescript:
Code:
-- List of all volume values.
set VolumeList to ¬
    {0, 6, 13, 19, 25, 32, 37, 43, 49, 56, 64, 69, 74, 82, 88, 94, 100}
set VolumeListLen to count of VolumeList

-- Get the current OS volume level.
set CurrentVolume to output volume of (get volume settings)
set VolumeIndex to 1

-- Determine what the current volume level is so that the volume
-- can be lowered.
repeat with VolumeFound in VolumeList
    if VolumeFound ≥ CurrentVolume then
        exit repeat
    end if
    
    -- Did not find the current volume level so look at the next value.    
    set VolumeIndex to VolumeIndex + 1
end repeat

-- Determine what the next lower volume level will be.
if VolumeIndex > 1 then
    set VolumeIndex to VolumeIndex - 1
end if

set PrevVolume to item VolumeIndex of VolumeList

-- Volume down.
set volume output volume PrevVolume
(This post was last modified: 2011-02-12 21:21 by winestock.)
find quote
jhkrischel Offline
Junior Member
Posts: 1
Joined: Nov 2011
Reputation: 0
Post: #8
Had a bit of a struggle getting this working, but here's what I did:

1) put my scripts in /Users/Shared/scripts (I was iffy on whether or not the relative dir was working...might not have been the problem)

2) updated the array of volume numbers:

{0, 6, 13, 19, 25, 32, 37, 43, 50, 56, 64, 70, 74, 82, 88, 94, 100}

The down volume was working intermittently, and using the applescript editor, I tracked it down to a mismatch between 49/50, 69/70.

Works great now!
find quote
h1ll37 Offline
Junior Member
Posts: 1
Joined: Jul 2012
Reputation: 0
Post: #9
(2011-11-03 01:26)jhkrischel Wrote:  Had a bit of a struggle getting this working, but here's what I did:

1) put my scripts in /Users/Shared/scripts (I was iffy on whether or not the relative dir was working...might not have been the problem)

2) updated the array of volume numbers:

{0, 6, 13, 19, 25, 32, 37, 43, 50, 56, 64, 70, 74, 82, 88, 94, 100}

The down volume was working intermittently, and using the applescript editor, I tracked it down to a mismatch between 49/50, 69/70.

Works great now!

I did all of this and only the VolumeUp works... volume down does nothing but the volume slider doesn't pop up either... I'm using the first generation of apple remotes i don't know if that matters.

Thanks,
find quote