diff --git a/packages/addons/service/spotify-connect-web/changelog.txt b/packages/addons/service/spotify-connect-web/changelog.txt index 9455e1f3c8..3b45459299 100644 --- a/packages/addons/service/spotify-connect-web/changelog.txt +++ b/packages/addons/service/spotify-connect-web/changelog.txt @@ -1,2 +1,13 @@ +8.0.101 +- Use mixer card index +- Add instructions to the addon settings +- Add a configuration wizard to assist with ALSA configuration +- Enable setting initial volume +- Activate onboard audio interface if no audio interface is active +- Activate known audio interface if selected but inactive +- Only set the playback route for RPi2 onboard audio interface +- Remove default settings +- Fix the erroneous bit rate setting + 8.0.100 - Initial addon diff --git a/packages/addons/service/spotify-connect-web/package.mk b/packages/addons/service/spotify-connect-web/package.mk index eb5bdeb162..b609d84f68 100644 --- a/packages/addons/service/spotify-connect-web/package.mk +++ b/packages/addons/service/spotify-connect-web/package.mk @@ -18,9 +18,9 @@ PKG_NAME="spotify-connect-web" PKG_VERSION="0.0.3-alpha" -PKG_REV="100" +PKG_REV="101" PKG_ARCH="arm" -PKG_ADDON_PROJECTS="RPi2" +PKG_ADDON_PROJECTS="RPi2 WeTek_Core WeTek_Play" PKG_LICENSE="prop." PKG_SITE="https://github.com/Fornoth/spotify-connect-web" PKG_URL="https://github.com/Fornoth/spotify-connect-web/releases/download/$PKG_VERSION/${PKG_NAME}_$PKG_VERSION.tar.gz" diff --git a/packages/addons/service/spotify-connect-web/source/bin/spotify-connect-web.start b/packages/addons/service/spotify-connect-web/source/bin/spotify-connect-web.start index d57f127fe7..383d5f2516 100755 --- a/packages/addons/service/spotify-connect-web/source/bin/spotify-connect-web.start +++ b/packages/addons/service/spotify-connect-web/source/bin/spotify-connect-web.start @@ -17,42 +17,110 @@ # along with LibreELEC. If not, see . ################################################################################ +. /etc/os-release . /etc/profile oe_setup_addon service.spotify-connect-web +chmod +x "$ADDON_DIR/spotify-connect-web" mkdir -p "$ADDON_HOME" +activate_card() { + if [ -e "/proc/asound/$1" ] + then + return + fi + if [ "$LIBREELEC_ARCH" == "RPi2.arm" -a "$1" == "ALSA" ] + then + dtparam audio=on + sleep 1 + else + echo "Do not know how to activate card $1 on $LIBREELEC_ARCH" + exit + fi +} + +if [ ! "$(cat /proc/asound/pcm 2> /dev/null)" ] +then + if [ "$LIBREELEC_ARCH" == "RPi2.arm" ] + then + activate_card "ALSA" + else + echo "Do not how how to activate an audio interface on $LIBREELEC_ARCH" + ko="ko" + fi +fi + if [ ! -f "$ADDON_HOME/spotify_appkey.key" ] then - echo "Exiting: no key" - exit + echo "Key not found" + ko="ko" +fi + +if [ ! "$scw_u" ] +then + echo "Username not set" + ko="ko" fi if [ ! "$scw_p" ] then - echo "Exiting: no password" - exit + echo "Password not set" + ko="ko" fi -if [ ! "$scw_u" ] +if [ ! "$scw_o" ] +then + echo "Playback device not set" + ko="ko" +fi + +if [ "$ko" ] then - echo "Exiting: no username" exit fi -amixer &> /dev/null || dtoverlay dtparam audio=on -amixer cset numid=3 "$pcm_3" +case "$scw_o" in -[ "$scw_b" ] && scw_B="-b $scw_b" -[ "$scw_m" ] && scw_M="-m $scw_m" -[ "$scw_o" ] && scw_O="-o $scw_o" + *:CARD=*) + card="${scw_o##*:CARD=}" + activate_card "$card" + index="$(readlink /proc/asound/$card)" + index="${index##*card}" + ;; -cd $ADDON_DIR -chmod +x spotify-connect-web -./spotify-connect-web $scw_B \ + hw:*,*) + echo "The hw:d,s specification is unreliable, use device:CARD=card instead" + index="${scw_o##hw:}" + index="${index%%,*}" + card="card$index" + activate_card "$card" + ;; + + *) + echo "Unknown playback device specification $swc_o" + exit + ;; + +esac + +[ "$scw_m" ] && [ "$vol_0" ] && amixer -c "$index" set "$scw_m" "$vol_0%" + +if [ "$LIBREELEC_ARCH" == "RPi2.arm" -a \ + "$(readlink /proc/asound/ALSA)" == "card$index" ] +then + [ "$pcm_3" ] && amixer -c "$index" cset name="PCM Playback Route" "$pcm_3" +fi + +[ "$scw_b" == "-" ] && scw_b="" +[ "$scw_b" ] && scw_b="-b $scw_b" +[ "$scw_m" ] && scw_m="-m $scw_m" + +cd "$ADDON_DIR" +./spotify-connect-web $scw_b \ -k "$ADDON_HOME/spotify_appkey.key" \ - $scw_M \ + $scw_m \ -n "$HOSTNAME" \ - $scw_O \ + -o "$scw_o" \ -p "$scw_p" \ - -u "$scw_u" + -u "$scw_u" \ + --mixer_device_index "$index" diff --git a/packages/addons/service/spotify-connect-web/source/resources/language/English/strings.po b/packages/addons/service/spotify-connect-web/source/resources/language/English/strings.po index a245897ecb..d9e8181af9 100644 --- a/packages/addons/service/spotify-connect-web/source/resources/language/English/strings.po +++ b/packages/addons/service/spotify-connect-web/source/resources/language/English/strings.po @@ -3,66 +3,110 @@ msgid "" msgstr "" -msgctxt "#30000" +msgctxt "#30100" msgid "Configuration" msgstr "" -msgctxt "#30001" +msgctxt "#30101" msgid "Spotify" msgstr "" -msgctxt "#30002" -msgid "username" +msgctxt "#30102" +msgid "Username" msgstr "" -msgctxt "#30003" -msgid "password" +msgctxt "#30103" +msgid "Password" msgstr "" -msgctxt "#30004" -msgid "bit rate" +msgctxt "#30104" +msgid "Bit rate" msgstr "" -msgctxt "#30005" -msgid "" +msgctxt "#30105" +msgid "-" msgstr "" -msgctxt "#30006" +msgctxt "#30106" msgid "90" msgstr "" -msgctxt "#30007" +msgctxt "#30107" msgid "160" msgstr "" -msgctxt "#30008" +msgctxt "#30108" msgid "320" msgstr "" -msgctxt "#30009" +msgctxt "#30109" msgid "ALSA" msgstr "" -msgctxt "#30010" -msgid "playback device" +msgctxt "#30110" +msgid "Configuration wizard" msgstr "" -msgctxt "#30011" -msgid "playback route" +msgctxt "#30111" +msgid "Playback device" msgstr "" -msgctxt "#30012" +msgctxt "#30112" +msgid "Mixer" +msgstr "" + +msgctxt "#30113" +msgid "Initial volume" +msgstr "" + +msgctxt "#30114" +msgid "Playback route" +msgstr "" + +msgctxt "#30115" msgid "auto detect" msgstr "" -msgctxt "#30013" +msgctxt "#30116" msgid "headphone jack" msgstr "" -msgctxt "#30014" +msgctxt "#30117" msgid "HDMI" msgstr "" -msgctxt "#30015" -msgid "mixer" +msgctxt "#30200" +msgid "Instructions" +msgstr "" + +msgctxt "#30201" +msgid "1. Copy your spofify_appkey.key the addon's home folder" +msgstr "" + +msgctxt "#30202" +msgid "2. Enter your Spotify username and password" +msgstr "" + +msgctxt "#30203" +msgid "3. Configure ALSA with the wizard" +msgstr "" + +msgctxt "#30204" +msgid "4. Save the settings" +msgstr "" + +msgctxt "#30205" +msgid "5. Play Spotify through the addon, using a Spotify app as a remote" +msgstr "" + +msgctxt "#30206" +msgid "5. Enjoy!" +msgstr "" + +msgctxt "#30210" +msgid "No playback device" +msgstr "" + +msgctxt "#30211" +msgid "Could not find a playback device" msgstr "" diff --git a/packages/addons/service/spotify-connect-web/source/resources/settings.xml b/packages/addons/service/spotify-connect-web/source/resources/settings.xml index b5fa3ae32c..8ffb1e01e9 100644 --- a/packages/addons/service/spotify-connect-web/source/resources/settings.xml +++ b/packages/addons/service/spotify-connect-web/source/resources/settings.xml @@ -1,13 +1,25 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/packages/addons/service/spotify-connect-web/source/settings-default.xml b/packages/addons/service/spotify-connect-web/source/settings-default.xml deleted file mode 100644 index 4549ca602a..0000000000 --- a/packages/addons/service/spotify-connect-web/source/settings-default.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/packages/addons/service/spotify-connect-web/source/wizard.py b/packages/addons/service/spotify-connect-web/source/wizard.py new file mode 100644 index 0000000000..be4455dc60 --- /dev/null +++ b/packages/addons/service/spotify-connect-web/source/wizard.py @@ -0,0 +1,53 @@ +################################################################################ +# This file is part of LibreELEC - https://libreelec.tv +# Copyright (C) 2016 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 . +################################################################################ + +import alsaaudio as alsa +import xbmcaddon +import xbmcgui + +if __name__ == "__main__": + + addon = xbmcaddon.Addon("service.spotify-connect-web") + dialog = xbmcgui.Dialog() + strings = addon.getLocalizedString + + while True: + pcms = alsa.pcms()[1:] + if len(pcms) == 0: + dialog.ok(strings(30210), strings(30211)) + break + pcmx = dialog.select(strings(30111), pcms) + if pcmx == -1: + break + pcm = pcms[pcmx] + pair = pcm.split(":CARD=") + device = pair[0] + card = pair[1].split(",")[0] + cardx = alsa.cards().index(card) + mixers = [mixer for mixer in alsa.mixers(cardindex=cardx, device=device) + if 'Playback Volume' in alsa.Mixer(control=mixer, cardindex=cardx).volumecap()] + if len(mixers) == 0: + mixer = "" + else: + mixerx = dialog.select(strings(30112), mixers) + if mixerx == -1: + continue + mixer = mixers[mixerx] + addon.setSetting("scw_m", mixer) + addon.setSetting("scw_o", pcm) + break