How to play a video from a USB

is there a guide on how to use OSMC? specifically randomly playing videos from a usb stick.
Sorry to ask such a dumb question but I cannot find a user guide anywhere.


(side note, the interface is working very badly for selecting list items on the PI -its like the cursor is drawn in the wrong position)

Videos > Files. Your USB stick should be listed there.

1 Like

With OSMC, USB connected storage will automatically be mounted at Videos>Files>Root Filesystem>/Media><label of USB drive>

Connect a Keyboard and use arrow buttons, or configure a remote. Kodi itself is not really designed for mouse control.

1 Like

So to randomly play videos from the USB stick?

Please explain exactly what you mean here?

He probably wants Kodi to start playing the files in a random order.

There is a simple way using a button during playback, but unfortunately it’s skin dependent. See the image below:

That’s the Estouchy skin (strangely it’s not present in the desktop counterpart). See if it’s also there somewhere in the OSMC skin.

Yes, it’s called Shuffle in the OSMC skin. Not clear whether if you select Repeat and Shuffle it shuffles before each repeat or just re-plays them in the shuffled order, though.

if I have 5 videos, play them in a random order, repeat forever.
Also new question – audio quality is terrible??


I think something like this may do want you require and it is not skin dependent.

you need to change the path in the script, to path of your usb drive so:


needs to change to something like:

path=/Media/<label of USB drive>

Also you need to save the desscribed script as,

Thanks Tom.

1 Like

thanks thats great!

ok Ive got this to work, it creates a random playlist & loops the playlist, however I would like the videos to be random so that the order is changing all the time. Is that possible? thanks!

shuffle does it once then always plays in the same shuffled sequence. So 1,2,3,4,5 shuffled goes say, 5,1,2,4,3 then that just repeats, 5,1,2,4, 3,5,1,2,4, 3,5,1,2,4,3


There is probably a better way to do this, its needs someone who is better at python than I. I’ve just thrown something quick together, as I had used this script before and was interested to see if it was possible to randomize playback.

# Autoplay videodirectory
import os, xbmc, time

while True:

        # set path to dir you want to play
        path="/media/<label of USB drive>"


        videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)

        for fname in dirList:
                videoList.add(path + "\\" + fname)

        # shuffle playlist

# put playlist on repeat

        # play playlist
        time.sleep( 310 )

I’ve commented out the repeatAll part and created a loop, with While True:

time.sleep( 310 )

This is in seconds and needs to be slightly longer than the total running time of all the clips.

import os, xbmc, time

I’ve added time to the imported modules, so the sleep function works probably.

I’ve only tested this to the point of checking it reorders the clips, so a couple of runs only. So if crashes after that, apologies.

Thanks Tom.

Thanks Tom, that works.
But can I ask what is the Time.Sleep for ? How much extra time in seconds to add after the run time? Would I geusstimate the load time of the movies and add that?
I think it recreates the playlist randomly, but will the Time.Sleep cut a movie short if its already playing and it gets called? I’m attempting to randomly play 8 movies for an art show and dont want it to be ugly. Related question - is there a way to hide the movie loading progress roundel thing? i would prefer just black


The time.sleep, stops the script from running again, so clips do not get cut off halfway through. (If isn’t there no clips play, it just keeps rerunning the script.) So you need the total time of the clips + about 2 seconds. Like I said before, I’ve not tested this thoroughly, If I was you; I would do so before putting it into production.

Thanks Tom.

where to save this script on raspberry pi and also what will b script?

raspberry pi osmc doesnt have userdata folder


~/.kodi/userdata. You will need command line access.

nano ~/.kodi/userdata/

(enter what is required in the script) ctrl-x and yes to save.

What do you require the script to do?


i want to automatically scan and play all videos from USB device when pluggged in