External players

From Official Kodi Wiki
Jump to navigation Jump to search
Cleanup.png This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions.

While the built in video and audio players are capable, out of the box, to handle a huge variety of content, users might find themselves in need of using a different playback software but still using Kodi for scraping and organizing content. Reasons might include improved post-processing abilities, DRM restricted media that requires a specific player (such as encrypted Blu-ray discs), special player-specific features, etc. Kodi has a powerful tool to achieve this, the external player. The current method involves the configuration of a playercorefactory.xml file.

Set up

Kodi comes with a default playercorefactory.xml file, located under the Kodi/System folder (where Kodi is the chosen installation folder).

To customize playback behaviour, users need to create an extra playercorefactory.xml file inside their userdata folder.

Let's start with an example playercorefactory.xml file:

    <player name="MPC-HC" type="ExternalPlayer" audio="false" video="true">
      <filename>C:\Program Files\MPC-HC\mplayerc.exe</filename>
      <args>"{1}" /fullscreen /close</args>
  <rules action="prepend">
    <rule filetypes="mkv" filename=".*720p.*" player="MPC-HC"/>

The <players/> node (i.e. <players>...<players/>) defines all the different players that you wish to add to Kodi. Inside you can have any number of <player/> nodes, defining as many external players as you wish (the builtin ones being dvdplayer and paplayer, you can also use the aliases audiodefaultplayer, videodefaultplayer, videodefaultdvdplayer).

The player name attribute can be anything you like and will appear in the "Play using..." menu, accessible from the context menu. For an external player the type attribute must be ExternalPlayer. The other possible values being dvdplayer and paplayer, although there's no point defining one of those as they already exist and don't accept any configuration. The audio and video (boolean; true/false) attributes when true will cause the player to always appear in the "Play using..." menu even if you don't define any rules for the player, or no rules match the currently selected media item (e.g. video file) for the player. You could, for instance, define a player with video="true" and then not tie it to any specific rule, thus creating some sort of "safety net", always available in the context menu, should you ever need it.

The only required node for a player with type ExternalPlayer is the <filename/> node, this should contain the path of the external player executable. The other, optional, nodes are

Name Value Use
args Arguments to pass to the external player executable.

If this contains the token {0} then this is replaced with the full URI of the item to be played (note that this is, in many cases, Kodi-specific and your external player won't understand it).
A {1} token is also replaced with the URI of the item to be played, but with the following differences

  • For rar and zip files {1} is the path of the archive and {2} will be the relative path to the file in the archive
  • On win32 smb-URIs (smb://host/path) are converted into UNCs (\\host\path)
  • For LiveTV streams/files the pvr:// type url is not translated and {1} still returns the Kodi-specific URI which will not be interpretable by the external player

NOTE you should surround these tokens with double-quotes (e.g. "{1}") unless you know what you're doing and have a good reason not to, as they may contain spaces.
If none of these tokens are present then it's equivalent to having "{1} at the end.

hidexbmc false (default)
whether to hide the Kodi window whilst the external player is active
hideconsole false (default)
Win32 only - whether the external player process is started with the initial window hidden (useful for hiding the console when the external player is a batch file)
warpcursor none (default)
Win32 only - whether and where to move the cursor to before the external player is launched
playcountminimumtime number of seconds the time the extplayer process needs to run for before the item's playcount will be incremented (i.e. it will be marked as watched)
playonestackitem false (default)
whether playback should stop after playing one item that's part of a stack

Once a user has defined one or more external player, they have the option of adding rules to customize which files are handled by which players. The above example, for instance, defines the MPC-HC external player as the default player for MKV files with "720p" in their filename. .* before and after "720p" is a regular expression (regex).

  • . "Matches any single character."
  • * "Matches the preceding element zero or more times."

Together they mean "Matches any single character (.) zero or more times (*)".

A <rules/> node contains a set of rules. An (optional) action attribute can have a value of prepend, append or overwrite which specifies whether the rules should be prepended, appended (the default if no action is specified) or replace all existing rules. Appended rules will take precedence over default players (i.e. DVDPlayer for video and PAPlayer for audio) but not over Kodis builtin rules. [needs better/more complete explanation]

A <rule/> node compares its attributes against the attributes of a media item and if everything matches then the player names in the player attribute is the default player for the media item (you can still select another using the "Play using..." menu). The attributes are listed below. Order of <rule/>s is significant [needs clarification], the first match defines the player so order them from more-to-less specific.

<rule/>s can be nested with inner rules inheriting attributes from outer rules, with inner rules being checked before outer rules. For example:

 <rules action="prepend">
  <rule video="true" player="wmplayer">
    <rule dvd="true" player="dvdplayer"/>
    <rule filetypes="mkv" player="VLC">
      <rule filename=".*720.*|.*1080.*" player="MPC-HC"/>

says that all video should be played by wmplayer, except DVDs, that are played with (the builtin) dvdplayer, and .mkv files that are played with VLC, however .mkv files with "720" or "1080" in their names are played with MPC-HC (all assuming wmplayer, VLC and MPC-HC players are defined in the players section).

The following attributes can be used to build rules:

Attribute Type Value
name string name of the rule
internetstream boolean when true the rule applies to internet streams
remote boolean when true the rule applies to remote-only (non-local) media
audio boolean when true the rule applies to audio-only media
video boolean when true the rule applies to video media
dvd boolean when true the rule applies to DVDs
dvdimage boolean when true the rule applies to DVD images (iso)
dvdfile boolean when true the rule applies to DVD folder structures
protocols regexp when defined the rule applies to items whose (URI) protocol matches; as well as "real" protocols like daap, rtv, rtsp Kodi also uses the URI protocol for things like zip, rar etc.
filetypes regexp when defined the rule applies to items whose file extension matches
mimetypes regexp when defined the rule applies to items whose mime-type matches
filename regexp when defined the rule applies to items whose filename matches
player string the name of the player defined in the <players> section this rule invokes

For the regexp attributes you can specify alike with a |-separator, e.g. mkv|avi|divx ("The choice operator matches either the expression before or the expression after the operator").

The following attributes are also available for video items with metadata (a.k.a. flagging):

Attribute Type Value
videocodec regexp matched against the video codec so, a rule could used xvid|divx|div3|div4|div5
videoresolution regexp matched against the video resolution, which will be one of 480, 540, 720 or 1080
videoaspect boolean matched against the video aspect ratio, which will be one of 1.33, 1.66, 1.78, 1.85, 2.20 or 2.35
hdrtype regexp matched against the video hdr type, which could be one of none (=sdr video), hdr10, hlg or dolbyvision - v22 and above
audiocodec regexp matched against the audio codec, e.g. ac3|dts
audiochannels regexp matched against the number of channels in the audio which will be an integer (i.e. 6 rather than 5.1)


On Kodi for Android running on TI OMAP pandaboard I was able to take advantage of hw acceleration by changing /data/data/org.xbmc.kodi/cache/apk/assets/system/playercorefactory.xml to launch Gallery on mp4 files as follows:


    <!-- These are compiled-in as re-ordering them would break scripts
    The following aliases may also be used:
      audiodefaultplayer, videodefaultplayer, videodefaultdvdplayer
    <player name="DVDPlayer" audio="true" video="true" />
    <player name="DVDPlayer" /> placeholder for MPlayer
    <player name="PAPlayer" audio="true" />
    <player name="Gallery" type="ExternalPlayer" audio="true" video="true">
       <args>start -n com.android.gallery3d/.app.MovieActivity -d {1}</args>
    <player name="DVDPlayer" audio="true" video="true" />
  <rules name="system rules">
    <rule name="rtv" protocols="rtv" player="DVDPlayer" />
    <rule name="hdhomerun/myth/mms/udp" protocols="hdhomerun|myth|cmyth|mms|mmsh|udp" player="DVDPlayer" />
    <rule name="lastfm/shout" protocols="lastfm|shout" player="PAPlayer" />
    <!-- dvdplayer can play standard rtsp streams -->
    <rule name="rtsp" protocols="rtsp" filetypes="!(rm|ra)"  player="PAPlayer" />
    <!-- Internet streams -->
    <rule name="streams" internetstream="true">
      <rule name="aacp/sdp" mimetypes="audio/aacp|application/sdp" player="DVDPlayer" />
      <rule name="mp2" mimetypes="application/octet-stream" filetypes="mp2" player="PAPlayer" />
    <!-- DVDs -->
    <rule name="dvd" dvd="true" player="DVDPlayer" />
    <rule name="dvdimage" dvdimage="true" player="DVDPlayer" />
    <!-- Only dvdplayer can handle these normally -->
    <rule name="sdp/asf" filetypes="sdp|asf" player="DVDPlayer" />
    <!-- Pass these to dvdplayer as we do not know if they are audio or video -->
    <rule name="nsv" filetypes="nsv" player="DVDPlayer" />
    <rule name="dgb" filetypes="*.mp4" player="Gallery"/>
    <!-- pvr radio channels should be played by dvdplayer because they need buffering -->
    <rule name="radio" filetypes="pvr" filename=".*/radio/.*" player="DVDPlayer" />

I tested this only very lightly but it improved playback smoothness and obviously reduced cpu load. ymmv.


In GNU/Linux the location of the file should be: ~/.kodi/userdata/playercorefactory.xml

There are cross-platform standalone video players which are supported by Kodi. Hereunder are two of them. The Full-screen option has been added, otherwise you will have a windowed video player.


    <player name="VLC" type="ExternalPlayer" audio="false" video="true">
      <args>--fullscreen "{1}"</args>
  <rules action="prepend">
    <rule video="true" player="VLC"/>


    <player name="MPV" type="ExternalPlayer" audio="false" video="true">
      <args>--fs=yes "{1}"</args>
  <rules action="prepend">
    <rule video="true" player="MPV"/>

See also