snapclient: initial addon

This commit is contained in:
awiouy 2018-03-04 08:41:14 +01:00
parent c8c57fba6e
commit 1e54f6b690
10 changed files with 319 additions and 0 deletions

View File

@ -0,0 +1,2 @@
100
- Initial addon

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -0,0 +1,47 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2018-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
PKG_NAME="snapclient"
PKG_VERSION="0.13.0"
PKG_REV="100"
PKG_ARCH="any"
PKG_LICENSE="GPLv3"
PKG_DEPENDS_TARGET="toolchain snapcast"
PKG_SECTION="service"
PKG_SHORTDESC="Snapclient: Synchronous multi-room audio client"
PKG_LONGDESC="Snapclient ($PKG_VERSION) is a Snapcast client. Snapcast is a multi-room client-server audio system, where all clients are time synchronized with the server to play perfectly synced audioplays."
PKG_AUTORECONF="no"
PKG_IS_ADDON="yes"
PKG_ADDON_NAME="Snapclient"
PKG_ADDON_TYPE="xbmc.service.library"
PKG_MAINTAINER="Anton Voyl (awiouy)"
make_target() {
:
}
makeinstall_target() {
:
}
addon() {
mkdir -p "$ADDON_BUILD/$PKG_ADDON_ID/bin"
cp "$(get_build_dir snapcast)/client/snapclient" \
"$ADDON_BUILD/$PKG_ADDON_ID/bin"
}

View File

@ -0,0 +1,40 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2018-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
import os.path
import subprocess
import xbmcaddon
import xbmcgui
SNAPCLIENT = os.path.join(
xbmcaddon.Addon().getAddonInfo('path'), 'bin', 'snapclient')
card = ''
cards = []
lines = subprocess.check_output([SNAPCLIENT, '--list']).splitlines()
for line in lines:
if line != '':
card = card + ' ' + line
else:
cards.append(card)
card = ''
dialog = xbmcgui.Dialog()
dialog.select(xbmcaddon.Addon().getLocalizedString(30015), cards)
del dialog

View File

@ -0,0 +1,51 @@
#!/bin/sh
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2018-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
. /etc/profile
oe_setup_addon service.snapclient
. /etc/os-release
case "$LIBREELEC_ARCH" in
RPi*.arm)
if [ "$sc_a" == "true" ]; then
ALSA="/proc/asound/ALSA"
if [ ! -e "$ALSA" ]; then
echo "Starting Raspberry Pi onboard audio"
dtparam audio=on
sleep 1
fi
if [ -e "$ALSA" ]; then
echo "Setting Raspberry Pi onboard audio playback route"
index="$(readlink $ALSA)"
index="${index##*card}"
amixer -c "$index" cset name="PCM Playback Route" "$sc_r"
fi
fi
;;
esac
[ -n "$sc_h" ] && sc_H="--hostID $sc_h"
[ -n "$sc_s" ] && sc_S="--soundcard $sc_s"
snapclient \
--daemon "$sc_n" \
$sc_H \
--latency "$sc_l" \
--port "$sc_p" \
$sc_S

View File

@ -0,0 +1,70 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2018-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
import subprocess
import xbmc
import xbmcaddon
def systemctl(command):
subprocess.call(
['systemctl', command, xbmcaddon.Addon().getAddonInfo('id')])
class Monitor(xbmc.Monitor):
def __init__(self, *args, **kwargs):
xbmc.Monitor.__init__(self)
self.player = Player()
def onSettingsChanged(self):
self.player.start('restart')
class Player(xbmc.Player):
def __init__(self):
super(Player, self).__init__(self)
self.start('start')
def onPlayBackEnded(self):
if xbmcaddon.Addon().getSetting('sc_k') == 'true':
xbmc.sleep(500)
if not self.isPlaying():
systemctl('start')
def onPlayBackStarted(self):
if xbmcaddon.Addon().getSetting('sc_k') == 'true':
systemctl('stop')
def onPlayBackStopped(self):
if xbmcaddon.Addon().getSetting('sc_k') == 'true':
systemctl('start')
def start(self, command):
if xbmcaddon.Addon().getSetting('sc_k') == 'true':
if self.isPlaying():
systemctl('stop')
else:
systemctl(command)
else:
systemctl(command)
if __name__ == '__main__':
Monitor().waitForAbort()

View File

@ -0,0 +1,70 @@
# Kodi Media Center language file
# Addon Name: snapclient
# Addon id: service.snapclient
# Addon Provider: Team LibreELEC
msgid ""
msgstr ""
msgctxt "#30000"
msgid "Snapclient"
msgstr ""
msgctxt "#30001"
msgid "List sound cards"
msgstr ""
msgctxt "#30002"
msgid "Sound card"
msgstr ""
msgctxt "#30003"
msgid "Host ID"
msgstr ""
msgctxt "#30004"
msgid "Port"
msgstr ""
msgctxt "#30005"
msgid "Priority"
msgstr ""
msgctxt "#30006"
msgid "Latency"
msgstr ""
msgctxt "#30007"
msgid "Kodi"
msgstr ""
msgctxt "#30008"
msgid "Stop Snapclient when Kodi plays"
msgstr ""
msgctxt "#30009"
msgid "Rasperry Pi"
msgstr ""
msgctxt "#30010"
msgid "Manage onboard audio"
msgstr ""
msgctxt "#30011"
msgid "Onboard audio playback route"
msgstr ""
msgctxt "#30012"
msgid "Autodetect"
msgstr ""
msgctxt "#30013"
msgid "Jack"
msgstr ""
msgctxt "#30014"
msgid "HDMI"
msgstr ""
msgctxt "#30015"
msgid "Available sound cards"
msgstr ""

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="30000">
<setting label="30001" type="action" action="RunAddon(service.snapclient)"/>
<setting label="30002" type="text" id="sc_s" default=""/>
<setting label="30003" type="text" id="sc_h" default=""/>
<setting label="30004" type="number" id="sc_p" default="1704"/>
<setting label="30005" type="slider" id="sc_n" default="-3" range="-20,1,19" option="int"/>
<setting label="30006" type="slider" id="sc_l" default="0" range="0,1,100" option="int"/>
</category>
<category label="30007">
<setting label="30008" type="bool" id="sc_k" default="false"/>
</category>
<category label="30009">
<setting label="30010" type="bool" id="sc_a" default="false"/>
<setting label="30011" type="enum" id="sc_r" lvalues="30012|30013|30014" visible="eq(-1,true)"/>
</category>
</settings>

View File

@ -0,0 +1,10 @@
<settings>
<setting id="sc_a" value="false" />
<setting id="sc_h" value="" />
<setting id="sc_k" value="false" />
<setting id="sc_l" value="0" />
<setting id="sc_n" value="-3" />
<setting id="sc_p" value="1704" />
<setting id="sc_r" value="0" />
<setting id="sc_s" value="" />
</settings>

View File

@ -0,0 +1,11 @@
[Unit]
Description=Snapclient
After=kodi.service network-online.target sound.target
Requires=kodi.service network-online.target sound.target
[Service]
Type=forking
ExecStart=/bin/sh /storage/.kodi/addons/service.snapclient/bin/snapclient.start
[Install]
WantedBy=kodi.target