install.sh: route Kodi audio to HDMI + ensure media roots exist
- After Kodi starts, set audiooutput.audiodevice to the HDMI sink via JSON-RPC (Kodi otherwise defaults to the analog jack). Waits for the web server, is overridable via MEDIAPI_KODI_AUDIO_DEVICE. - mkdir the configured MEDIAPI_MEDIA_ROOTS so browsing works and there's a spot to copy content into. Verified live on the Pi: playback + HDMI audio work end to end via the app's Player.Open path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
afe1ab3e2f
commit
99b5c27e65
2 changed files with 30 additions and 0 deletions
|
|
@ -20,6 +20,9 @@ MEDIAPI_KODI_HOST=127.0.0.1
|
||||||
MEDIAPI_KODI_PORT=8090
|
MEDIAPI_KODI_PORT=8090
|
||||||
MEDIAPI_KODI_USER=kodi
|
MEDIAPI_KODI_USER=kodi
|
||||||
MEDIAPI_KODI_PASSWORD=changeme
|
MEDIAPI_KODI_PASSWORD=changeme
|
||||||
|
# Kodi audio output. Default routes to the Pi's first HDMI port (Kodi otherwise
|
||||||
|
# picks the analog jack). Override for the 2nd HDMI port (vc4hdmi1) if needed.
|
||||||
|
#MEDIAPI_KODI_AUDIO_DEVICE=ALSA:hdmi:CARD=vc4hdmi0,DEV=0|vc4-hdmi-0
|
||||||
|
|
||||||
# --- System: the Linux user the systemd services run as ---
|
# --- System: the Linux user the systemd services run as ---
|
||||||
# Auto-detected from whoever runs install.sh (id -un) when left unset, so you
|
# Auto-detected from whoever runs install.sh (id -un) when left unset, so you
|
||||||
|
|
|
||||||
27
install.sh
27
install.sh
|
|
@ -154,6 +154,16 @@ deploy_current() {
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends kodi
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends kodi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Ensure the media browse roots exist so browsing works and there's a place to
|
||||||
|
# copy content into. (mkdir -p is a no-op if it's already a mount point.)
|
||||||
|
IFS=':' read -ra _media_roots <<< "${MEDIAPI_MEDIA_ROOTS:-/localmedia}"
|
||||||
|
for r in "${_media_roots[@]}"; do
|
||||||
|
[[ -n "$r" && ! -d "$r" ]] || continue
|
||||||
|
echo "==> Creating media root $r ..."
|
||||||
|
sudo mkdir -p "$r"
|
||||||
|
sudo chown "${MEDIAPI_USER}:${MEDIAPI_USER}" "$r"
|
||||||
|
done
|
||||||
|
|
||||||
echo "==> Applying WiFi country + AP config ..."
|
echo "==> Applying WiFi country + AP config ..."
|
||||||
sudo raspi-config nonint do_wifi_country "${MEDIAPI_WIFI_COUNTRY}"
|
sudo raspi-config nonint do_wifi_country "${MEDIAPI_WIFI_COUNTRY}"
|
||||||
if nmcli -g NAME con show | grep -qx "${MEDIAPI_AP_CONN_NAME}"; then
|
if nmcli -g NAME con show | grep -qx "${MEDIAPI_AP_CONN_NAME}"; then
|
||||||
|
|
@ -191,6 +201,23 @@ deploy_current() {
|
||||||
echo "==> Starting services ..."
|
echo "==> Starting services ..."
|
||||||
sudo systemctl restart mediapi-kodi
|
sudo systemctl restart mediapi-kodi
|
||||||
sudo systemctl restart mediapi-app
|
sudo systemctl restart mediapi-app
|
||||||
|
|
||||||
|
# Route Kodi's audio to HDMI. Kodi otherwise defaults to the Pi's analog jack
|
||||||
|
# (bcm2835 Headphones). Done live over JSON-RPC once Kodi's web server is up
|
||||||
|
# (more robust than seeding guisettings, since Kodi validates the device).
|
||||||
|
local kodi_url="http://${MEDIAPI_KODI_USER:-kodi}:${MEDIAPI_KODI_PASSWORD:-kodi}@127.0.0.1:${MEDIAPI_KODI_PORT:-8090}/jsonrpc"
|
||||||
|
local audio_dev="${MEDIAPI_KODI_AUDIO_DEVICE:-ALSA:hdmi:CARD=vc4hdmi0,DEV=0|vc4-hdmi-0}"
|
||||||
|
echo "==> Setting Kodi audio output to HDMI ..."
|
||||||
|
for _ in $(seq 1 30); do
|
||||||
|
if curl -fsS --max-time 3 "$kodi_url" -H 'content-type: application/json' \
|
||||||
|
-d '{"jsonrpc":"2.0","id":1,"method":"JSONRPC.Ping"}' 2>/dev/null | grep -q pong; then
|
||||||
|
curl -fsS --max-time 5 "$kodi_url" -H 'content-type: application/json' \
|
||||||
|
-d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"Settings.SetSettingValue\",\"params\":{\"setting\":\"audiooutput.audiodevice\",\"value\":\"${audio_dev}\"}}" >/dev/null \
|
||||||
|
&& echo " audio -> ${audio_dev}" || echo " WARNING: could not set Kodi audio device"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- health check ---------------------------------------------------
|
# --- health check ---------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue