Video stops playing after a few minutes

I’m running Kodi on a Xiaomi Android TV set-top box. Video stops playing after a few minutes(mostly 18-24mins) and back to file selection UI. I can re-select the file and resume from where it stopped.
I’ve tried Kodi v16.1, v17 and SPMC v16.5.5, all with the same problem except SPMC paused instead of stopped. And I’ve tried files on NAS and ext HDD, same thing. I’ve also tried cabled, 2.4G wifi and 5G wifi network connection with NAS, problem persist.
Other video player works fine with all the situations, I feel like it is a problem with Kodi itself. Anyone have any clue with this frustrating problem?