Style Picker Plugin

mp4e:style-picker lets viewers choose a look from rows of named options. Each pick sets a variable your video reads.

Overview

Style picker (mp4e:style-picker, an official plugin) lets a viewer choose what the video shows while it plays. Each row is a text variable with named options. A pick sets the variable, and anything that reads the variable follows, such as a replacement zone that shows a different variant.

Style picker is a family plugin: it has the family's six themes, its common style settings, its minimum readable size and its keyboard and TV-remote navigation.

Adding a picker to a video

  1. Create a text variable for each choice, and read it where it matters, as {{style_lamp}}.
  2. Install Style picker from the marketplace and add a Style picker overlay. It sits in a top corner of its box, so place the box at the top of the frame, where it stays clear of the player's controls. Keep the box under half the frame, and object cards will stay clear of it too.
  3. Enter the rows (below).
  4. Pick a theme and a size. Lean-back is for a TV across the room.

Rows

The rows setting lists the rows:

PropTypeDefaultDescription
idstring-The row's id, named by the rowChanged event. Required.
labelstring-The small label before the row, and the tab on a phone. Defaults to the id.
variablestring-The text variable a pick sets. Defaults to the id.
currentstring-The variable's value, as "{{variable}}", so the row stays right when a rule or your page sets the variable.
options{ key, name, thumb? }[]-What to choose from. key is the value a pick sets and may be empty; name is what the viewer reads; thumb is a picture from the project's media (media://...) or an https address, shown on a phone's tiles. With no picture the tile shows the first letter of the name.
presetboolean-A row with no variable of its own: a pick sets every other row to the same key, and it shows the key they all share (none when they differ). Leave variable and current out.
A preset row and two rows of options
{
  "rows": [
    { "id": "style", "label": "Style", "preset": true,
      "options": [
        { "key": "",      "name": "Empty" },
        { "key": "north", "name": "North" },
        { "key": "coast", "name": "Coast" }
      ] },
    { "id": "lamp", "label": "Lamp",
      "variable": "style_lamp", "current": "{{style_lamp}}",
      "options": [
        { "key": "",      "name": "Empty" },
        { "key": "north", "name": "North", "thumb": "media://lamp_north" },
        { "key": "coast", "name": "Coast", "thumb": "media://lamp_coast" }
      ] },
    { "id": "chair", "label": "Chair",
      "variable": "style_chair", "current": "{{style_chair}}",
      "options": [
        { "key": "",      "name": "Empty" },
        { "key": "north", "name": "North" },
        { "key": "coast", "name": "Coast" }
      ] }
  ]
}

Settings

Besides these, Style picker has the family's common style settings.

PropTypeDefaultDescription
rowsRow[] | string[]The rows, in order (shape below). Also JSON text. With no rows the plugin shows nothing.
align'right' | 'left''right'The top corner of the overlay's box the picker sits in.
hintstring'Tap to choose a look'A line under the picker at the start, and once more on the second pass of a loop if nobody has picked. Empty: no invitation.
shuffleLabelstring'Mix'The text on the Mix button.

How it behaves

  • The whole tray where it fits, a deck on a phone. The tray has a row of chips per variable. It gives way to the deck when the player is phone-sized, or when the tray would not fit its box, or would take over half the video's width or 60% of its height. The deck has a tab per row and big tiles for the row in hand. On a very short video the tiles get shorter, then the deck becomes one line: the row's name, which a tap moves to the next row, and its options.
  • Mix chooses at random across the rows and never repeats the combination on screen. It shows how many looks the rows make.
  • It follows the variables. When a rule, your page or another plugin sets a variable, its row shows the new value. A value none of the options has leaves nothing selected in that row.
  • Tappable while the video plays. Only the tray or the deck takes the pointer (through clickable regions); every click elsewhere goes through to the video.
  • A keyboard or TV remote moves between the options with the arrows; Enter picks and Back leaves.
  • An https picture on a host that limits plugin network access needs its domain allowed. Pictures from the project's media always load.

Actions

Through pluginAction from rules, other plugins and input shortcuts, or callPluginAction from your page:

PropTypeDefaultDescription
next{}-Take the preset row's next option (when the rows differ, its first option with a key), or a random mix when there is no preset row. It does nothing once the viewer has picked, so a video that loops can change the look on each pass until the viewer chooses.
At the end of a scene that loops, before seeking back
{ "type": "pluginAction", "pluginId": "mp4e:style-picker", "actionId": "next", "config": {} }

Events

PropTypeDefaultDescription
rowChanged{ row, key, by }-A row was set. row is the row's id, key the option's key, by is viewer (a tap), shuffle (Mix) or loop (the next action). A preset pick emits it for each row it changed and then for the preset row.

Rules hear it as plugin:mp4e:style-picker:rowChanged; your page hears it through onEvent:

Track what viewers choose
<MP4EPlayer
  src="/video.mp4"
  onEvent={(event, data) => {
    if (event === 'plugin:emit' && data.event === 'rowChanged') {
      // { row, key, by }
      analytics.track('look_chosen', data.data);
    }
  }}
/>