Auto-play and resume videos on USB

  • I am installing a RPi4 in my car for the kids to watch shows on. I’d like to (a) have it start playing without any intervention, (b) have it resume wherever it was when power was cut, (c) loop back to the first video once finished.

    I found an autoplay script on the forum from a while ago and that works. Then I tried using the Kodi resume plugin from github.

    Autoplay worked but the resume did not. I suspect because the script just starts right from the beginning.

  • (b) have it resume wherever it was when power was cut

    Autoplay worked but the resume did not. I suspect because the script just starts right from the beginning

    Not many media players (if any) know what happened when you suddenly yank out the power cable.

    Kodi too does not keep track of played files that way.

  • So is there a way to modify this script to play if there is no resume point saved but if there is, just resume?

    Code
    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)')