2014-06-14, 18:53
I'm trying to create my first XBMC addon for my openelec Frodo XBMC installation on a headless Raspberry Pi. It is a simple script to stop any music playing, play a doorbell sound, and then restart the music. It will be triggered by Jsonrpc from my server, connected to a doorbell. I have set up the addon in .xbmc/addons/script.module.doorbell and created addon.xml, addon.py and a resources/media directory holding the doorbell sound. If I plug a monitor into the RPi, the addon shows up in the Programs section so has been recognised, but it doesn't seem to play the doorbell sound if I click on it.
The script is in addon.py and looks like this:
Not sure if I need the gubbins at the beginning, but I saw it in an example script so put it in there!
My addon.xml looks like this:
When I call the script the json call reports success, but the script doesn't work and my xbmc.log contains the following:
Can anybody see something I'm doing wrong, or tell me what else I should investigate? Any help much appreciated.
The script is in addon.py and looks like this:
Code:
# Doorbell script. Pauses audio if playing, then plays doorbell
# and restarts audio if relevant
import sys, xbmc, xbmcaddon
__addon__ = xbmcaddon.Addon(id='script.module.doorbell')
__addonname__ = __addon__.getAddonInfo('name')
__icon__ = __addon__.getAddonInfo('icon')
# Doorbell sound is in addon resources/media directory
media = 'special://home/addons/script.module.doorbell/resources/media/doorbell.wav'
playing = xbmc.Player().isPlaying()
if playing:
xbmc.Player().pause()
xbmc.playSFX(media)
if playing:
xbmc.Player().play()
Not sure if I need the gubbins at the beginning, but I saw it in an example script so put it in there!
My addon.xml looks like this:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.doorbell" name="Doorbell" version="0.0.1"
provider-name="Ivan Mactaggart">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="xbmc.addon" version="12.0.0"/>
</requires>
<extension point="xbmc.python.script" library="addon.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">Doorbell</summary>
<description lang="en">Plays a doorbell sound</description>
<disclaimer lang="en"></disclaimer>
<language></language>
<platform>all</platform>
<license></license>
<forum></forum>
<website></website>
<email></email>
<source></source>
</extension>
</addon>
When I call the script the json call reports success, but the script doesn't work and my xbmc.log contains the following:
Code:
16:40:21 T:2925569120 NOTICE: Thread XBPyThread start, auto delete: false
16:40:21 T:2925569120 NOTICE: -->Python Interpreter Initialized<--
16:40:22 T:3047276544 ERROR: GetDirectory - Error getting plugin://script.module.doorbell
16:40:22 T:3047276544 ERROR: CGUIMediaWindow::GetDirectory(plugin://script.module.doorbell) failed
Can anybody see something I'm doing wrong, or tell me what else I should investigate? Any help much appreciated.