External players

While the built in DVDPlayer (video) and PAPlayer (audio) 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 XBMC 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.

XBMC has a powerful tool to achieve this, the external player. The current method involves the configuration of a playercorefactory.xml file.

Set up
XBMC comes with a default playercorefactory.xml file, 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:  C:\Program Files\MPC-HC\mplayerc.exe "{1}" /fullscreen /close false false none 

The  node (i.e.  )  defines all the different players that you wish to add to XBMC. Inside you can have any number of  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  attribute can be anything you like and will appear in the [[Media:Playusing.png|"Play using..." menu]], accessible from the context menu. For an external player the  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  and   (boolean; true/false) attributes when   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  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  ExternalPlayer is the   node, this should contain the path of the external player executable. The other, optional, nodes are

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  node contains a set of rules. An (optional)  attribute can have a value of ,   or   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 XBMCs builtin rules. [needs better/more complete explanation]

A  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 s is significant [needs clarification], the first match defines the player so order them from more-to-less specific.

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

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: 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):

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

 am       start -n com.android.gallery3d/.app.MovieActivity -d {1} true true          <rule name="dvdimage" dvdimage="true" player="DVDPlayer" /> <rule name="sdp/asf" filetypes="sdp|asf" player="DVDPlayer" /> <rule name="nsv" filetypes="nsv" player="DVDPlayer" /> <rule name="dgb" filetypes="*.mp4" player="Gallery"/> <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.