Skip to content

Instantly share code, notes, and snippets.

@airbornelamb
Last active November 8, 2023 14:27
Show Gist options
  • Save airbornelamb/e66eb76a1ee436ab5f73a04fea7cb5ab to your computer and use it in GitHub Desktop.
Save airbornelamb/e66eb76a1ee436ab5f73a04fea7cb5ab to your computer and use it in GitHub Desktop.
OSMC autoplay file on startup

Purpose: These files will allow you to setup Kodi/OSMC to autoplay a playlist on bootup. Useful for kiosks or TVs that you want to use to play a stream. I use this with a Raspberry Pi 3B+ running OSMC from the Raspberri Pi Imager https://www.raspberrypi.com/software/

  1. Within ~/.kodi/addons/service.autoexec/ create addon.xml and autoexec.py
  2. Within ~/.kodi/userdata/playlists/video/ create streamtest.m3u and edit the file to reference whatever you want to play
  3. Enable the autoexec service by navigating in the menu to Settings > Add-ons > My add-ons > Services > Autoexec Service
  4. You can watch the log file using the command tail -F /home/osmc/.kodi/temp/kodi.log to ensure that it starts the playlist. Now when you reboot it should wait 15 seconds and play from your playlist.

Reference: https://kodi.wiki/view/Autoexec_Service

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.autoexec" name="Autoexec Service" version="1.0.0" provider-name="osmc">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
</requires>
<extension point="xbmc.service" library="autoexec.py">
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en_US">Automatically run python code when Kodi starts.</summary>
<description lang="en_US">The Autoexec Service will automatically be run on Kodi startup.</description>
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE Version 2</license>
</extension>
</addon>
#!/usr/bin/python
import xbmc
import time
time.sleep(15)
xbmc.executebuiltin('PlayMedia("/home/osmc/.kodi/userdata/playlists/video/streamtest.m3u")')
#EXTM3U
#EXTINF:-1
rtsp://rtsp.stream/pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment