Kodi Community Forum

Full Version: Autostart of Kodi and playing WAV file in a loop.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Howdy all,

Using a Raspberry Pi Zero 2, I need to have Kodi autostart, load a WAV files from the microSD card then loop play the file.

After looking at some of the posts on this site, it seems like what I am trying to do is so simple that nobody needs help in making it work, as people are getting into remote servers and other more complex (to me) issues.

Some of the posts were saying that Kodi was not made to be used headless and recommended other products, but I want to use Kodi as the WAV file I want to play is a 7.1 surround recording and I wasn't able to get VLC to play 7.1 on a Raspberry Pi.  I have no problem using a different player, but Kodi is able to play all 8 channels perfectly, I just don't know how to get it to autostart and auto load/play/loop.

Thanks for reading my post,

phil
I can't help for the autostart issue, as I don't know which OS you are using and you haven't even mentioned it. But the autoplay-issue is somewhat easy. 

You have to use the "Autoexec Service": https://kodi.wiki/view/Autoexec_Service
  • SSH into the RPi Zero
  • navigate to ~/.kodi/addons
  • create a folder "service.autoexec": mkdir service.autoexec
  • navigate to that folder: cd service.autoexec
  • use any editor you like and create the file "addon.xml". For example with nano: nano addon.xml and fill it with the following content:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.autoexec" name="Autoexec Service" version="1.0.0" provider-name="your username">
  <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_GB">Automatically run python code when Kodi starts.</summary>
  <description lang="en_GB">The Autoexec Service will automatically be run on Kodi startup.</description>
  <platform>all</platform> <license>GNU GENERAL PUBLIC LICENSE Version 2</license>
  </extension>
</addon>
  • save that file
  • use the same editor and create a "autoexec.py" file at the same directory and fill it with the following content:
Code:
import xbmc

xbmc.executebuiltin('PlayMedia(/full/path/to/file.mp3)')
xbmc.executebuiltin('PlayerControl(RepeatOne)')
  • Make sure you use the full path to the file on your system
On next start of Kodi the file should be played and repeat is set to "RepeatOne" which means the player should only repeat this file.
The above script using python "3" is for Matrix onwards . Is it possible to change the python version and use on Leia ?
I used to use the old way of booting directly into an addon , via the userdata , but I can't find the guide for it and according to the wiki it's deprecated ?
Found an old tutorial , sorted. Stick below text in an autoexec.py file and drop it in userdata folder.
import xbmc
xbmc.executebuiltin( "RunAddon(name of addon/plugin)" )
xbmc.executebuiltin( "PlayerControl(RepeatAll)" )