External players

From Official Kodi Wiki
Revision as of 16:12, 8 July 2009 by >Ashlar
Jump to navigation Jump to search

While the built in DVDplayer and PAPlayer 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.
Reasons might include improved postprocessing abilities, GPU accelerated video decoding and other special features not (yet) offered by the internal players. Thanks to several brave developers we have a powerful tool at our disposal: the external player option.
There are currently two different ways of accessing this functionality. The first is found in XBMC Babylon and involves advancedsettings.xml, the second one can be found in the bleeding edge builds (or if you compile directly) and it involves the configuration of a playercorefactory.xml file, through which we can alter the default player for different sources (videos, music, DVDs, etc.) and add as many external players as needed.

advancedsettings.xml method

To customize playback behaviour, users need to create an advancedsettings.xml file inside their "\UserData\" folder.
Please consult the plaform specific FAQ for the appropriate location.

An example: <xml><advancedsettings> <video>

 <defaultplayer>externalplayer</defaultplayer>

</video> <externalplayer>

 <filename>c:\applications\mplayer\mplayer.exe</filename>
 <args>-fs</args>
 <forceontop>true</forceontop>
 <hidexbmc>true</hidexbmc>
 <hideconsole>false</hideconsole>
 <hidecursor>false</hidecursor>

</externalplayer> </advancedsettings></xml>

<video/defaultplayer> - use this to force the default video player to externalplayer
<filename/> - absolute location of the executable to launch (MPC, Media Player, MPlayer, Zoom Player etc.)
<args/> - arguments you want to pass to the player you launch (depending on players used, these could include launching in fullscreen, closing on playback completion, etc.)

Tweaks:

<forceontop/> - (suggested setting: false) set to true to attempt to force problematic players to be on top. Note that this doesn't work for some players. If you are having problems with XBMC staying 'in front' of your application (you are using zoomplayer or you get a frozen XBMC window), set this to false. with this set to true, alt-tab works again
<hidexbmc/> - set to true to hide the XBMC program (doesn't display on the taskbar)
<hideconsole/> - (suggested setting: false) set to true to hide a launched console (useful for MPlayer for windows which opens a console window before starting playback)
<hidecursor/> - (suggested setting: false) set to true to position the cursor offscreen (useful for MPC for example)

Note, you can also set externalplayer as the default audio player:

<xml><advancedsettings> <audio>

 <defaultplayer>externalplayer</defaultplayer>

</audio></xml>

If you don't need these and want to use the default players (dvdplayer/paplayer), don't include the defaultplayer and audio/video tags!

When browsing video content, bring up the context menu and select ExternalPlayer to play the content using your external player. If you set defaultplayer you won't have to.

If your player doesn't launch, you need to enable debug mode and check the XBMC log for all CEXTPlayer notices.

playercorefactory.xml method

XBMC, since r20983, comes with a default playercorefactory.xml, located under the XBMC\System folder (where XBMC is the chosen installation folder).

To customize playback behaviour, users need to create an extra playercorefactory.xml file inside their "\UserData\" folder.
Please consult the plaform specific FAQ for the appropriate location.

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

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

</playercorefactory></xml>

The <players/> node defines all the different players that you wish to add to XBMC. Inside you can have a potentially infinite 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 aready exist and don't accept any configuration). The audio and video (boolean) 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 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.

<filename/> - should contain the path of the external player executable

<args/> - should contain arguments to pass to the external player executable.

<hidexbmc/> - win32 only - should contain true or false (default), when true the XBMC window is hidden whist the external player is active

<hideconsole/> - win32 only - should contain true or false (default), when true the external player process is started with the initial window hidden (useful for hiding the console when the external player is a batch file)

<hidecursor/> - win32 only - should contain true or false (default), when true the cursor is moved to the bottom-right of the screen before the external player is launched

<forceontop/> its purpose is to remove the XBMC window's ONTOP attribute when the external-player is playing and put it back afterwards.

Once a user has defined one or more external player, he has 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 a suffix of 720p in their filename.

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.

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 significat, the first match defines the player so order then from more-to-less specific.

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

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

</rules></xml>

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:

internetstream

   boolean - true matches an internet stream

audio

   boolean - true matches audio-only media

video

   boolean - true matches video media

dvd

   boolean - true matches a DVD

dvdimage

   boolean - true matches a DVD image (iso)

dvdfile

   boolean - true matches a DVD folder structure

protocols

   regexp - matched against the (URI) protocol, as well as "real" protocols like
   daap, rtv, rtsp XBMC also uses the URI protocol for things like zip, rar etc.

filetypes

   regexp - matched against the file extension, again

mimetypes

   regexp - matched against the mime-type of the media

filename

   regexp - matched against the filename

player

   string - the name of the player defined in the <players> section

For the regexp attributes you can specify a like with a |-separator, e.g. mkv|avi|divx