I actually almost have a way to do this using udev, but it doesn't work because udev won't finish until the all udev rules have run, so it's not possible (with the current tools) to do this (that I have found yet).
It can be done with some modifications:
/storage/.config/udev.rules.d/99-usb-play.rules
Code
IMPORT{builtin}="blkid"
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd*|mmc*", ENV{ID_FS_USAGE}=="filesystem", \
RUN+="/usr/bin/systemd-run /storage/autoplay.sh /dev/%k"
/storage/autoplay.sh
Bash
#!/bin/sh
sleep 5
MP=$(printf '%b' $(grep "^${1} " /proc/self/mounts | cut -d ' ' -f 2))
if [ -f "${MP}/kodi.playme" ]
then
/usr/bin/kodi-send --action="PlayMedia(\"${MP}\", isdir)"
fi
This limits auto play to USB drives with existing /kodi.playme file.