# MPlayer skin format

## Overview

### Skin components

Skins are quite free-format (unlike the fixed-format skins of Winamp/XMMS, for example), so it is up to you to create something great.

Currently there are four windows to be decorated: the main window, the video window, the playbar, and the skin menu.

- The main window is where you can control MPlayer. The playbar shows up in fullscreen mode when moving the mouse to the bottom of the screen. The background of the windows is an image. Various items can (and must) be placed in the window: buttons, potmeters (sliders) and labels. For every item, you must specify its position and size.

  A button has three states (pressed, released, disabled), thus its image must be divided into three parts placed below each other. See the button item for details.

  A potmeter (mainly used for the seek bar and volume/balance control) can have any number of phases by dividing its image into different parts. See hpotmeter for details.

  Labels are a bit special: The characters needed to draw them are taken from an image file, and the characters in the image are described by a font description file. The latter is a plain text file which specifies the x,y position and size of each character in the image (the image file and its font description file form a font together). See dlabel and slabel for details.

  All images can have full transparency as described in the section about image formats. If the X server doesn't support the XShape extension, the parts marked transparent will be black. If you'd like to use this feature, the width of the main window's background image must be dividable by 8.

- The video window is where the video appears. It can display a specified image if there is no movie loaded (it is quite boring to have an empty window :-)) Note: transparency is not allowed here.

- The skin menu is just a way to control MPlayer by means of menu entries (which can be activated by a middle mouse button click). Two images are required for the menu: one of them is the base image that shows the menu in its normal state, the other one is used to display the selected entries. When you pop up the menu, the first image is shown. If you move the mouse over the menu entries, the currently selected entry is copied from the second image over the menu entry below the mouse pointer (the second image is never shown as a whole).

  A menu entry is defined by its position and size in the image (see the section about the skin menu for details).

There is an important thing not mentioned yet: For buttons, potmeters and menu entries to work, MPlayer must know what to do if they are clicked. This is done by messages (events). For these items you must define the messages to be generated when they are clicked.

### Image formats

Images must be PNGs—either truecolor (24 or 32 bpp) or 8 bpp with a RGBA color palette.

In the main window and in the playbar (see below) you can use images with `transparency': Regions filled with the color #FF00FF (magenta) are fully transparent when viewed by MPlayer. This means that you can even have shaped windows if your X server has the XShape extension.

### Files

You need the following files to build a skin:

- The configuration file named skin tells MPlayer how to put different parts of the skin together and what to do if you click somewhere in the window.

- The background image for the main window.

- Images for the items in the main window (including one or more font description files needed to draw labels).

- The image to be displayed in the video window (optional).

- Two images for the skin menu (they are needed only if you want to create a menu).

With the exception of the skin configuration file, you can name the other files whatever you want (but note that font description files must have a `.fnt` extension).

## The skin file

As mentioned above, this is the skin configuration file. It is line oriented; comments start with a '`;`' character and continue until the end of the line, or start with a '`#`' character at the beginning of the line (in that case only spaces and tabs are allowed before the '`#`').

The file is made up of sections. Each section describes the skin for an application and has the following form:

    section = section name
    .
    .
    .
    end

Currently there is only one application, so you need only one section: its name is movieplayer.

Within this section each window is described by a block of the following form:

    window = window name
    .
    .
    .
    end

where window name can be one of these strings:

- main - for the main window

- video - for the video window

- playbar - for the playbar

- menu - for the skin menu

(The video, playbar and menu blocks are optional - you do not need to decorate the video window, have a playbar or create a menu. A default menu is always available by a right mouse button click.)

Within a window block, you can define each item for the window by a line in this form:

    item = parameter

Where `item` is a string that identifies the type of the GUI item, `parameter` is a numeric or textual value (or a list of values separated by commas).

Putting the above together, the whole file looks something like this:

    section = movieplayer
      window = main
      ; ... items for main window ...
      end

      window = video
      ; ... items for video window ...
      end

      window = menu
      ; ... items for menu ...
      end

      window = playbar
      ; ... items for playbar ...
      end
    end

The name of an image file must be given without leading directories - images are searched for in the `skins` directory. You may (but you need not) specify the extension of the file. If the file does not exist, MPlayer tries to load the file `<filename>.<ext>`, where `png` and `PNG` are tried for `<ext>` (in this order). The first matching file will be used.

Finally some words about positioning. The main window and the video window can be placed in the different corners of the screen by giving `X` and `Y` coordinates. `0` is top or left, `-1` is center and `-2` is right or bottom, as shown in this illustration:

    (0, 0)----(-1, 0)----(-2, 0)
      |          |          |
      |          |          |
    (0,-1)----(-1,-1)----(-2,-1)
      |          |          |
      |          |          |
    (0,-2)----(-1,-2)----(-2,-2)

Here is an example to make this clear. Suppose that you have an image called `main.png` that you use for the main window:

    base = main, -1, -1

MPlayer tries to load `main`, `main.png`, `main.PNG` files and centers it.

### Main window and playbar

Below is the list of entries that can be used in the '`window = main`' ... '`end`', and the '`window = playbar`' ... '`end`' blocks.

`decoration = enable|disable`

  Enable or disable window manager decoration of the main window. Default is disable.

  This isn't available for the playbar.

`base = image, X, Y`

  Lets you specify the background image to be used for the main window. The window will appear at the given `X,Y` position on the screen. It will have the size of the image.

  Transparent regions in the image (colored #FF00FF) appear black on X servers without the XShape extension. The image's width must be dividable by 8.

`button = image, X, Y, width, height, message`

  Place a button of `width` * `height` size at position `X,Y`. The specified `message` is generated when the button is clicked. The image given by `image` must have three parts below each other (according to the possible states of the button), like this:

      +------------+
      |  pressed   |
      +------------+
      |  released  |
      +------------+
      |  disabled  |
      +------------+

  A special value of `NULL` can be used if you want no `image`.

`hpotmeter = button, bwidth, bheight, phases, numphases, default, X, Y, width, height, message`

`vpotmeter = button, bwidth, bheight, phases, numphases, default, X, Y, width, height, message`

`rpotmeter = button, bwidth, bheight, phases, numphases, x0, y0, x1, y1, default, X, Y, width, height, message`

  Place a horizontal (`hpotmeter`), vertical (`vpotmeter`) or rotary (`rpotmeter`) potmeter of `width` * `height` size at position `X,Y`. The image can be divided into different parts for the different phases of the potmeter (for example, you can have a pot for volume control that turns from green to red while its value changes from the minimum to the maximum). All potentiometers can have a button that can be dragged with a `hpotmeter` and `vpotmeter`. A `rpotmeter` can be spun even without a button. The parameters are:

  - `button` - the image to be used for the button (must have three parts below each other, like in case of button). A special value of `NULL` can be used if you want no image.

  - `bwidth`, `bheight` - size of the button

  - `phases` - the image to be used for the different phases of the potentiometer. A special value of `NULL` can be used if you want no such image. The image must be divided into `numphases` parts below each other (resp. side by side for `vpotmeter`) like this:

        +------------+
        |  phase #1  |                vpotmeter only:
        +------------+
        |  phase #2  |                +------------+------------+     +------------+
        +------------+                |  phase #1  |  phase #2  | ... |  phase #n  |
             ...                      +------------+------------+     +------------+
        +------------+
        |  phase #n  |
        +------------+

  - `numphases` - number of phases stored in the `phases` image

  - `x0`, `y0` and `x1`, `y1` - position of the 0% start point and 100% stop point for the potentiometer (`rpotmeter` only)

    The first coordinate `x0,y0` defines the 0% start point (on the edge of the potentiometer) in the individual image of phase #1 and the second coordinate `x1,y1` the 100% stop point in the individual image of phase #n - in other words, the coordinates of the tip of the mark on the potentiometer in the two single images (not in the image of all phases).

  - `default` - default value for the potentiometer (in the range `0` to `100`)

    (If message is `evSetVolume`, it's allowed to use a plain hyphen-minus as value. This will cause the currently set volume to remain unchanged.)

  - `X`, `Y` - position for the potentiometer

  - `width`, `height` - width and height of the potentiometer

  - `message` - the message to be generated when the value of the potentiometer is changed

`pimage = phases, numphases, default, X, Y, width, height, message`

  Place different phases of an image at position `X,Y`. This element goes nicely with potentiometers to visualize their state. `phases` can be `NULL`, but this is quite useless, since nothing will be displayed then. For a description of the parameters see hpotmeter. There is only a difference concerning the message:

  - `message` - the message to be reacted on, i.e. which shall cause a change of `pimage`.

`font = fontfile`

  Defines a font. `fontfile` is the name of a font description file with a `.fnt` extension (do not specify the extension here) and is used to refer to the font (see dlabel and slabel). Up to 25 fonts can be defined.

`slabel = X, Y, fontfile, "text"`

  Place a static label at the position `X,Y`. `text` is displayed using the font identified by `fontfile`. The text is just a raw string (`$x` variables do not work) that must be enclosed between double quotes (but the " character cannot be part of the text). The label is displayed using the font identified by `fontfile`.

`dlabel = X, Y, width, align, fontfile, "text"`

  Place a dynamic label at the position `X,Y`. The label is called dynamic because its text is refreshed periodically. The maximum width of the label is given by `width` (its height is the height of a character). If the text to be displayed is wider than that, it will be scrolled, otherwise it is aligned within the specified space by the value of the `align` parameter: `0` is for left, `1` is for center, `2` is for right.

  The text to be displayed is given by `text`: It must be written between double quotes (but the " character cannot be part of the text). The label is displayed using the font identified by `fontfile`. You can use the following variables in the text:

  Variable | Meaning
  --- | ---
  $1 | elapsed time in hh:mm:ss format
  $2 | elapsed time in mmmm:ss format
  $3 | elapsed time in hh format (hours)
  $4 | elapsed time in mm format (minutes)
  $5 | elapsed time in ss format (seconds)
  $6 | running time in hh:mm:ss format
  $7 | running time in mmmm:ss format
  $8 | elapsed time in h:mm:ss format
  $v | volume in xxx.xx% format
  $V | volume in xxx.x format
  $U | volume in xxx format
  $b | balance in xxx.xx% format
  $B | balance in xxx.x format
  $D | balance in xxx format
  $$ | the $ character
  $a | a character according to the audio type (none: n, mono: m, stereo: t, surround: r)
  $t | track number (DVD, VCD, CD or playlist)
  $o | filename
  $O | filename (if no title name available) otherwise title
  $f | filename in lower case
  $F | filename in upper case
  $T | a character according to the stream type (file: f, CD: a, Video CD: v, DVD: d, URL: u, TV/DVB: b, CUE: c)
  $P | a character according to the playback state (stopped: s, playing: p, paused: e)
  $p | the p character (if a movie is playing)
  $s | the s character (if the movie is stopped)
  $e | the e character (if playback is paused)
  $g | the g character (if ReplayGain is active)
  $x | video width
  $y | video height
  $C | name of the codec used

  The `$a, $T, $P, $p, $s` and `$e` variables all return characters that should be displayed as special symbols (for example, e is for the pause symbol that usually looks something like ||). You should have a font for normal characters and a different font for symbols. See the section about symbols for more information.

### Video window

The following entries can be used in the '`window = video`' . . . '`end`' block.

`base = image, X, Y, width, height`

  The image to be displayed in the window. The window will be as large as the image. `width` and `height` denote the size of the window; they are optional (if they are missing, the window is the same size as the image). A special value of `NULL` can be used if you want no image (in which case `width` and `height` are mandatory).

`background = R, G, B`

  Lets you set the background color. It is useful if the image is smaller than the window. `R`, `G` and `B` specifies the red, green and blue component of the color (each of them is a decimal number from 0 to 255).

### Skin menu

As mentioned earlier, the menu is displayed using two images. Normal menu entries are taken from the image specified by the `base` item, while the currently selected entry is taken from the image specified by the `selected` item. You must define the position and size of each menu entry through the menu item.

The following entries can be used in the '`window = menu`'. . .'`end`' block.

`base = image`

  The image for normal menu entries.

`selected = image`

  The image showing the menu with all entries selected.

`menu = X, Y, width, height, message`

  Defines the `X,Y` position and the size of a menu entry in the image. `message` is the message to be generated when the mouse button is released over the entry.

## Fonts

As mentioned in the section about the parts of a skin, a font is defined by an image and a description file. You can place the characters anywhere in the image, but make sure that their position and size is given in the description file exactly.

The font description file (with `.fnt` extension) can have comments like the skin configuration file starting with '`;`' (or '`#`', but only at the beginning of the line). The file must have a line in the form

    image = image

Where `image` is the name of the image file to be used for the font (you do not have to specify the extension).

    "char" = X, Y, width, height

Here `X` and `Y` specify the position of the `char` character in the image (`0,0` is the upper left corner). `width` and `height` are the dimensions of the character in pixels. The character `char` shall be in UTF-8 encoding.

This example defines the A, B, C characters using `font.png`.

    ; Can be "font" instead of "font.png".
    image = font.png

    ; Three characters are enough for demonstration purposes :-)
    "A" =  0,0, 7,13
    "B" =  7,0, 7,13
    "C" = 14,0, 7,13

### Symbols

Some characters have special meanings when returned by some of the variables used in dlabel. These characters are meant to be shown as symbols so that things like a nice DVD logo can be displayed instead of the character '`d`' for a DVD stream.

The following table lists all the characters that can be used to display symbols (and thus require a different font).

Character | Symbol
--- | ---
p | play
s | stop
e | pause
n | no sound
m | mono sound
t | stereo sound
r | surround sound
g | replay gain
space | no (known)stream
f | stream is a file
a | stream is a CD
v | stream is a Video CD
d | stream is a DVD
u | stream is a URL
b | stream is a TV/DVB broadcast
c | stream is a cue sheet

## GUI messages

These are the messages that can be generated by buttons, potmeters and menu entries.

evNone

  Empty message, it has no effect.

Playback control:

evPlay

  Start playing.

evStop

  Stop playing.

evPause

  Pause playing.

evPrev

  Jump to previous track in the playlist.

evNext

  Jump to next track in the playlist.

evLoad

  Load a file (by opening a file selector dialog box, where you can choose a file).

evLoadPlay

  Does the same as `evLoad`, but it automatically starts playing after the file is loaded.

evLoadAudioFile

  Loads an audio file (with the file selector).

evLoadSubtitle

  Loads a subtitle file (with the file selector).

evDropSubtitle

  Disables the currently used subtitle.

evPlaylist

  Open/close the playlist window.

evPlayCD

  Tries to open the disc in the given CD-ROM drive.

evPlayVCD

  Tries to open the disc in the given CD-ROM drive.

evPlayDVD

  Tries to open the disc in the given DVD-ROM drive.

evPlayImage

  Loads an CD/(S)VCD/DVD image or DVD copy (with the file selector) and plays it as if it were a real disc.

evLoadURL

  Displays the URL dialog window.

evPlayTV

  Tries to start TV/DVB broadcast.

evPlaySwitchToPause

  The opposite of `evPauseSwitchToPlay`. This message starts playing and the image for the `evPauseSwitchToPlay` button is displayed (to indicate that the button can be pressed to pause playing).

evPauseSwitchToPlay

  Forms a switch together with `evPlaySwitchToPause`. They can be used to have a common play/pause button. Both messages should be assigned to buttons displayed at the very same position in the window. This message pauses playing and the image for the `evPlaySwitchToPause` button is displayed (to indicate that the button can be pressed to continue playing).

Seeking:

evBackward10sec

  Seek backward 10 seconds.

evBackward1min

  Seek backward 1 minute.

evBackward10min

  Seek backward 10 minutes.

evForward10sec

  Seek forward 10 seconds.

evForward1min

  Seek forward 1 minute.

evForward10min

  Seek forward 10 minutes.

evSetMoviePosition

  Seek to position (can be used by a potmeter; the relative value (0-100%) of the potmeter is used).

Video control:

evHalfSize

  Set the video window to half size.

evDoubleSize

  Set the video window to double size.

evFullScreen

  Switch fullscreen mode on/off.

evNormalSize

  Set the video window to its normal size.

evSetAspect

  Set the video window to its original aspect ratio.

evSetRotation

  Set the video to its original orientation.

Audio control:

evDecVolume

  Decrease volume.

evIncVolume

  Increase volume.

evSetVolume

  Set volume (can be used by a potmeter; the relative value (0-100%) of the potmeter is used).

evMute

  Mute/unmute the sound.

evSetBalance

  Set balance (can be used by a potmeter; the relative value (0-100%) of the potmeter is used).

evEqualizer

  Turn the equalizer on/off.

Miscellaneous:

evAbout

  Open the about window.

evPreferences

  Open the preferences window.

evSkinBrowser

  Open the skin browser window.

evMenu

  Open the (default) menu.

evIconify

  Iconify the window.

evExit

  Quit the program.

## Creating quality skins

So you have read up on creating skins for the MPlayer GUI, done your best with the Gimp and wish to submit your skin to us? Read on for some guidelines to avoid common mistakes and produce a high quality skin.

We want skins that we add to our repository to conform to certain quality standards. There are also a number of things that you can do to make our lives easier.

As an example you can look at the Blue skin, it satisfies all the criteria listed below since version 1.5.

- Each skin should come with a `README` file that contains information about you, the author, copyright and license notices and anything else you wish to add. If you wish to have a changelog, this file is a good place.

- There must be a file `VERSION` with nothing more than the version number of the skin on a single line (e.g. 1.0).

- Horizontal and vertical controls (sliders like volume or position) should have the center of the knob properly centered on the middle of the slider. It should be possible to move the knob to both ends of the slider, but not past it.

- Skin elements shall have the right sizes declared in the skin file. If this is not the case you can click outside of e.g. a button and still trigger it or click inside its area and not trigger it.

- The `skin` file should be prettyprinted and not contain tabs. Prettyprinted means that the numbers should line up neatly in columns and definitions should be indented appropriately.