Auto-play video files from USB drive upon insertion


  • You mucked something. Or you have files on your drive that crash kodi. Unplug all usb drives and SD cards and see if you think still crashes. If it does then something else is wrong that isn't related to this script.

    Re-tested and eliminated all other possible issues from the equation. Still crashes and then reboots even when running headless or running with HDMI video out only and no extra peripherals.


  • What happens when you run the script manually?

    Code
    /storage/autoplay.sh

    I deleted the /storage/.config/udev.rules.d/99-usb-play.rules file and also the /storage/autoplay.sh file and then I was able to boot.
    I SSH to LibreElec and then re-created everything from scratch.
    Then I ran the autoplay.sh file as you instructed. I made sure both file permissions were 777.
    It automatically ran the contents from the USB drive fine which is a success.
    However, the mini sub-window (pop-up) that appears after inserting a USB drive asking me to play video, audio etc. from the newly inserted drive remained on the screen. I had to click on cancel for that to go away. There should be a way to suppress that sub-window (pop-up) when running fully peripheral-less.
    Then I rebooted.
    It went back to the infinite loop of booting up to the Jarvis logo and then crashing again and again.
    I kept it on for 10 minutes and it never stopped crashing and rebooting.
    Same crashing issue as mentioned before.


  • can you unplug the usb drive, let it boot up so kodi is running, then plug the usb drive back in?

    I disconnected the peripherals such as the USB drive, WiFi dongle, keyboard, mouse and then finally disconnected the USB hub - one by one - and retried more than 50 times. It crashes after showing the Jarvis splash/logo screen and briefly showing the GUI background image. Now, it stays off after crashing a few times. It does not try to reboot again and again into an infinite loop anymore.

    BTW, I am a hobbyist and not getting paid for this. So, my sincere apologies if I cannot respond to the postings in this forum right away due to my day job.

    Edited once, last by kmihmisc (November 17, 2016 at 1:39 AM).

  • I disconnected the peripherals such as the USB drive, WiFi dongle, keyboard, mouse and then finally disconnected the USB hub - one by one - and retried more than 50 times. It crashes after showing the Jarvis splash/logo screen and briefly showing the GUI background image. Now, it stays off after crashing a few times. It does not try to reboot again and again into an infinite loop anymore.

    BTW, I am a hobbyist and not getting paid for this. So, my sincere apologies if I cannot respond to the postings in this forum right away due to my day job.

    Any fix?

  • just came across this thread -- here's the fix:

    a. in udev rules, make sure the command is on a single line (see udev - Debian Wiki) before the backslash ('\') e.g.

    Code
    IMPORT{builtin}="blkid" ACTION=="add", SUBSYSTEM=="block", KERNEL=="sda*",  ENV{ID_FS_USAGE}=="filesystem", \
    RUN+="/usr/bin/systemd-run /storage/autoplay.sh /dev/%k"

    The original code in the thread pastes into several lines -- this is what caused boot loop most likely.

    b. the autorun.sh needs to start with #!/bin/sh -- otherwise systemd fails to run it. Thing is, this vital line was eaten by the forum parsing code. Try posting a code block here starting with '#'

  • Just for Leia Version

    #nano ~/.kodi/userdata/autoexec.py

    import xbmc,os

    caminho=os.popen("(mount | grep -i '/dev/sda1' | cut -d ' ' -f 3)").read().replace('/var','').strip()

    xbmc.executebuiltin('xbmc.PlayMedia("{0}","isdir")'.format(caminho))

    xbmc.executebuiltin('xbmc.PlayerControl(RepeatAll)')

    #chmod +x ~/.kodi/userdata/autoexec.py

    #reboot