BETABeta — some features and products are not available yet.
BuildDEV

Switching Off mediaPlayer's Built-in Controls and Building the Transport Yourself

media.toggle · media.seek · onTimeUpdate, checked on a call-review screen. The built-in controls were switched off so the current playback position could go into a button label, and on the MP3 copy of the same call the waveform did not draw.

makemindNov 26, 2026

I built a screen for a call-centre quality reviewer. The job itself is simple: listen to a recorded call and, where something looks wrong, press a button to leave a mark. But this screen does not use the built-in transport.

The call-review screen. Under the waveform in the middle, hand-built −15s · Pause · +15s buttons and a 0:31 / 0:47 readout; bottom right, a Mark 0:31 — dead air button. The MP3 copy panel top right shows a note icon instead of a waveform. Real render capture
The call-review screen. Under the waveform in the middle, hand-built −15s · Pause · +15s buttons and a 0:31 / 0:47 readout; bottom right, a Mark 0:31 — dead air button. The MP3 copy panel top right shows a note icon instead of a waveform. Real render capture

The reason was one button. Look at the Mark 0:31 — dead air button at the bottom right of the screen: the current playback position is inside the label. Before the reviewer leaves a mark, the minutes and seconds have to show on the button first. The built-in transport keeps the position inside itself and does not hand it out. That leaves no way to build that label.

So I switched it off.

{
  "type": "mediaPlayer",
  "id": "tape",
  "source": "bundle://assets/call-4417.wav",
  "mediaType": "audio",
  "controls": false,
  "waveform": true,
  "height": 150
}

The moment controls: false goes in, the play button, the position slider and the elapsed-time readout all disappear. Only the waveform remains. From here on, play, pause and seeking all have to be built in the document.

Play and pause

Toggling playback is done by passing the widget id to media.toggle.

{
  "type": "button",
  "label": "{{playing ? 'Pause' : 'Play'}}",
  "onTap": { "type": "media.toggle", "id": "tape" }
}

The label reads a playing state, and who fills that value matters a little. Not the button; the player.

"onPlay":  { "type": "state", "action": "set", "binding": "playing", "value": true },
"onPause": { "type": "state", "action": "set", "binding": "playing", "value": false }

Write it as "the button was pressed, so flip playing" and it soon drifts. When playback stops because the recording ended, the button was never pressed. So the state comes from what actually happened. If onEnded sets playing back to false and also resets the position to 0, pressing a finished recording again starts it from the beginning.

Finding out how far playback has got

onTimeUpdate keeps firing during playback. The event carries currentTime, so it can be taken straight into state.

"onTimeUpdate": {
  "type": "state",
  "action": "set",
  "binding": "at",
  "value": "{{event.currentTime}}"
}

Now at is a number of seconds that keeps updating, so the button label that was the original problem can be built.

"Mark {{floor(at / 60)}}:{{floor(at % 60) < 10 ? '0' : ''}}{{floor(at % 60)}} — dead air"

floor splits minutes and seconds, and a single-digit second gets a leading 0. The expression is untidy; there is no function that turns it straight into mm:ss, so this is how it is written. If the screen prints the time in several places this fragment repeats that many times, and it may be better to keep one more formatted string in state.

The buttons that skip 15 seconds are media.seek. Add to or subtract from the current at, and the slider under the waveform uses the same action.

This content requires Developer or above

Sign in and upgrade your plan to continue reading.

View Plans