Kodi is a media player which can be installed on your computer, on your phone and also on your Raspberry Pi! It is free & open source software and available at kodi.tv.

Kodi features a special action to quickly play random media called PartyMode. PartyMode starts playback immediately with random tracks out of the music library. The action accepts either music or video as parameter. Unfortunately video is not working at all, so it’s not possible to play random videos with the PartyMode feature.

If you have the goal to play random videos (movies, series, episodes) or music with Kodi, here you can find a solution. You will be able to start random playback from a remote client, shell or within Kodi itself. Kodi has a feature called Smart Playlists which allows to create a solution that is superior to a simple PartyMode for videos.

Why Smart Playlist instead of PartyMode

The option for music can be invoked by the action PartyMode(music) (how to trigger Kodi action).

What happens if you use PartyMode with video as parameter (like listed in Kodi documentation):

  • PartyMode sidebar is opened
  • No videos, or anything else is loaded into playlist
  • Empty playlist, thus no playback
  • Tested on Kodi 17.6 and Kodi 18 Alpha

Smart Playlists

What is this about?

Kodi supports smart playlists for all types of media (excluding pictures), which essentially use a set of rules to limit the results from the databases. This means that to be able to create a smart playlist in the GUI, music/video must first be added to the libraries using a scraper addon or by creating NFO files. Smart playlist can be created either by using the built-in GUI smart playlist editor accessible from the Playlists section, or by creating an XML file with the extension XSP (XBMC Smart Playlist). [Source]

Options

The table below lists all available options for smart playlists:

  • Type: Needs to be placed in the playlist xml file
  • Queue filled with: Queued items when random order is specified
  • Example playlist: Examples with reuse where possible
TypeQueue filled withExample playlist
moviesAny movie in libraryKung Fury, Forrest Gump
episodesEpisodes of any seriesSimpsons S0304, Community S0203
tvshowsComplete series with episodes in correct orderSmallville S0101, Smallville S0102, ... Simpsons S0101
music
songs
Songs from whole libraryWalking Disaster, Feeling This
albumsComplete albums with songs in correct orderWalking Disaster, Dear Father, With Me, ... Feeling This
musicvideosMusic videos21 Guns, Astronaut
mixedAll songs and music videos21 Guns, Feeling This

Create a Smart Playlist

Below is the content of a smart playlist with random playback of movies (replace movies with a value out of Type column).

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="movies">
    <name></name>
    <match>all</match>
    <order direction="ascending">random</order>
</smartplaylist>

Place the contents in a xml file inside Kodi userdata folder. Below is the required structure, place as much playlists as you want.

$ pwd
/home/user/.kodi/userdata/playlists
$ tree
├── mixed
│   └── PartyModeMusicAndMusicVideo.xsp
├── music
│   └── PartyModeMusicAlbums.xsp
└── video
    ├── PartyModeMovie.xsp
    └── PartyModeSeries.xsp

Examples

Random movies from one folder

This example is for you if you want to:

  • Limit & filter the elements to be played
  • Categorize media under a common filepath
  • Start random playback (regardless of metadata like movie title, release year)

Here all Bud Spencer & Terenece Hill movies are stored in a directory Bud Spencer somewhere in a movie folder that is indexed in the library.

By using a path-rule a filter with given path (/Bud Spencer/) is applied when you start the playlist.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="movies">
    <name>Movies: Buddy &amp; Terrence Hill</name>
    <match>all</match>
    <rule field="path" operator="contains">
        <value>/Bud Spencer/</value>
    </rule>
    <order direction="ascending">random</order>
</smartplaylist>

Save this at: .kodi/userdata/playlists/video/Filme-Buddy-Hill.xsp

Random episodes from a single series

This example is for you if you want to:

  • Limit & filter the elements to be played
  • Categorize media under a common filepath
  • Start random playback (regardless of metadata like movie title, release year)
  • Always play random episodes of a given series, so completlty unordered and out of any season

Here all episodes of The Simpsons series are stored in a common directory Simpsons somewhere in a folder that is indexed in the library.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="episodes">
    <name>Series: Simpsons</name>
    <match>all</match>
    <rule field="path" operator="contains">
        <value>/Simpsons/</value>
    </rule>
    <order direction="ascending">random</order>
</smartplaylist>

Save this at: .kodi/userdata/playlists/video/Series-Simpsons.xsp

More Examples

More examples, filter and limit options are available in the Kodi Wiki.

Start playback

Replace host and relative playlist path with own values.

  • Kodi
    Navigate to Playlists -> Smart Playlists, start playback of an item

  • JSON RPC API – POST request with curl
    curl -g --data-binary '{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": {"file": "special://profile/playlists/video/PartyModeSeries.xsp"} } }' --header 'content-type: application/json;' http://127.0.0.1/jsonrpc
    
  • kodi-send (only supports Music)
    $ kodi-send --action="PlayerControl(Partymode(Music))"
    
  • OpenHab 2
    Create a binding which executes shell script (either using Exec2 binding or a rule). Paste the curl command into the script, this way it is also useable without OpenHab. Another way is to make a request using HTTP bindings, but it requires proper encoding.