Play sound on button press?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
teaguecl Offline
Fan
Posts: 409
Joined: Apr 2010
Reputation: 22
Post: #1
I would like to play a navigation sound each time the "browser_home" key is pressed. Is there any way to do this via skinning? I know I can put it into the global keymap (via userdata/keyboard.xml or /usr/share/xbmc/system/keymaps/keyboard.xml) but I can't imagine asking everyone who installs my skin to modify their keymaps. I was expecting there to be a keyboard.xml inside the skin folder, but I haven't seen how to do that.
EDIT: I also know I could add it to sounds.xml in the <activate> of the "home" window - but that plays the sound every time I enter the home screen. I just want to play the sound when the browser_home key is pressed.

Habey BIS-6561 silent fanless HTPC + 2GB DDR2 RAM + Intel X25-V 40GB SSD + XBMCbuntu Eden + Tivo Slide qwerty remote | My latest XBMC patch
(This post was last modified: 2012-05-15 21:03 by teaguecl.)
find quote
Hitcher Offline
Skilled Skinner
Posts: 9,976
Joined: Aug 2007
Reputation: 67
Location: Eastleigh, UK
Post: #2
Check the skin's 'sounds' folder.

There's no Home button sound though you'll have to use 'parentdir' I guess.

[Image: sig_zps3af3b48e.jpg]
find quote
teaguecl Offline
Fan
Posts: 409
Joined: Apr 2010
Reputation: 22
Post: #3
Thanks for the suggestion Hitcher, unfortunately that doesn't work. parentdir is not the same as "activate the Home screen". I've been looking at it in detail, and the sound interface really is just too limited to do what I want. All it can do is play a sound whenever a window is activated. What I need is to play a sound conditionally when a window is activated.
I can see two ways of doing it - both of them require code changes. I'm not sure which design would be best.
1. Add some conditional values to sounds.xml. For my particular case, I'd like to know the "reason" the window was activated (e.g. Startup, Home button pressed, Back button pressed ..). A conditional that just checked the value of a skin setting would also work. I could set the value, activate the window, then clear the value.
2. In addition to the <window> and <action> tags in sounds.xml, add a <name> tag. The name tag allows you to define a name for a sound. Then, we could add an action called PlaySound and could do something like this in our skin:
Code:
<onleft>PlaySound(mySoundName)</onleft>

Method two is a little more manual, but I think it's the one I like best. Anyone have any feedback? Has anyone else run into skinning issues due to the limited navigation sound interface?

Habey BIS-6561 silent fanless HTPC + 2GB DDR2 RAM + Intel X25-V 40GB SSD + XBMCbuntu Eden + Tivo Slide qwerty remote | My latest XBMC patch
find quote
phil65 Offline
Skilled Skinner
Posts: 4,458
Joined: Mar 2009
Reputation: 56
Location: Cologne, Germany
Post: #4
you could put a setproperty(playsound,true,home) in keymaps before the window call (are several commands for one button allowed in keymaps?) and then use

<onload condition="!Player.HasMedia + !IsEmpty(Window(home).property(playsound))">Playmedia(...)</onload>
and clear that property afterwards.
would need a bit more adjusting in other areas to avoid that the nowplaying widgets do not show up when playin that specific sound file.

that´s only a dirty workaround though, i agree that the sound interface is rather limited for skinners.
(This post was last modified: 2012-05-16 18:15 by phil65.)
find quote
pieh Offline
Team-XBMC Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #5
@teaguecl
I must say I don't really like mixing sounds handling with gui in window/dialog .xml . Could you explain why do You want play GUI sound only with that particular key? Maybe after I'll get it I may be able to assist You on this one. Wink

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

My previous forum/trac nickname: grajen3
find quote