Moey Icons
No results. Try “dialog”, “dark” or “grid”.
Content

Audio & video

A player that looks like the rest of your app, for video, music, podcasts and voice notes — big touch targets, the keys people know from video sites, and nothing lost without JavaScript (the browser's own controls stay). Plus embeds — YouTube, Vimeo, maps — that load only when someone presses play.

Video

<div class="player max-w-2xl" id="pl-video" data-moey-player>
  <video src="media/sample.webm" poster="img/gallery/lisbon-dawn.svg" preload="metadata">
    <track kind="captions" src="media/sample.vtt" srclang="en" label="English">
  </video>
</div>

Step by step

  1. Write a normal <video> or <audio> with its src (and a poster for video).
  2. Wrap it in <div class="player" data-moey-player>. Moey takes away the browser's controls and puts its own: play, a seek bar with what's loaded, the time, speed, sound, captions (when there's a <track>), picture in picture and full screen.
  3. Choose the buttons with data-moey-controls="speed volume captions pip fullscreen" (play, the seek bar and the time are always there), or "none" for just those.
  4. Give it a name (aria-label, or a .player-title) so screen readers know which player it is.
Keys (on the player)What they do
Space · KPlay / pause
← → · J LBack / ahead 5 s · 10 s
↑ ↓ · MLouder / quieter · mute
F · C · 0–9Full screen · captions · jump to 0–90%

If a file is missing, the connection drops, or the browser can't play the format, the player doesn't just sit there: the bar says Can't play this file and offers Try again (data-moey-error-text="…" for your own words; listen for moey:player-error to log it).

On a video the controls step aside while it plays — move the mouse or tap to bring them back; a tap on a phone shows them, a second one pauses. Starting one player pauses any other that's playing.

Audio, with a cover

Morning chime
Moey sounds · 0:02
<div class="player max-w-md" id="pl-audio" data-moey-player>
  <div class="player-head">
    <img class="player-cover" src="img/gallery/dunes.svg" alt="">
    <div>
      <div class="player-title">Morning chime</div>
      <div class="player-sub">Moey sounds · 0:02</div>
    </div>
  </div>
  <audio src="media/chime.wav" preload="metadata"></audio>
</div>

A voice note in a chat

The same player, small, inside a chat bubble — only the speed button (data-moey-controls="speed"). Recordings made in the browser often don't say how long they are; the player finds out by itself.

AK
Ana · 9:41
<div class="chat-msg">
  <span class="avatar avatar-sm avatar-green avatar-subtle">AK</span>
  <div class="chat-bubbles">
    <div class="chat-bubble p-1">
      <div class="player player-audio bg-transparent" data-moey-player data-moey-controls="speed" aria-label="Voice note from Ana">
        <audio src="media/chime.wav" preload="metadata"></audio>
      </div>
    </div>
    <div class="chat-meta">Ana · 9:41</div>
  </div>
</div>

Just play and the time

<div class="player max-w-md" data-moey-player data-moey-controls="none" aria-label="Short sound">
  <audio src="media/chime.wav" preload="metadata"></audio>
</div>

Embeds that load on demand

An <a class="embed" data-moey-embed> shows a light cover with a play button. Only when it's pressed does the real player load — so pages stay fast, and nothing from YouTube or Vimeo reaches the visitor until they choose (YouTube's no-cookie player, Vimeo's do-not-track). Without JavaScript it's a plain link to the video.

<a class="embed max-w-2xl" href="https://www.youtube.com/watch?v=aqz-KE-bpKQ" data-moey-embed>
  <img src="img/gallery/harbor-night.svg" alt="">
  <span class="embed-play"></span>
  <span class="embed-title">Big Buck Bunny — a short film</span>
  <span class="embed-note">Plays from YouTube</span>
</a>

Shapes: 16:9 (default), .embed-4x3, .embed-1x1, .embed-9x16 for Shorts and Reels:

<a class="embed embed-9x16" href="https://www.youtube.com/shorts/aqz-KE-bpKQ" data-moey-embed>
  <img src="img/gallery/festival.svg" alt="">
  <span class="embed-play"></span>
  <span class="embed-title">A vertical clip</span>
</a>
<!-- any page, a map, a calendar: data-src + the cover you like -->
<a class="embed embed-4x3" href="https://www.openstreetmap.org/…" data-src="https://www.openstreetmap.org/export/embed.html?bbox=…" data-moey-embed>
  <span class="embed-play"><i class="mi mi-map"></i></span><span class="embed-title">Find us</span>
</a>

Want them in a full-screen viewer instead? Links to videos, audio and YouTube work in the Lightbox too.

Reference

Class / attributeWhat it does
.player[data-moey-player] > video | audioMoey's controls (the browser's without JavaScript)
data-moey-controls="speed volume captions pip fullscreen" · "none"Which buttons (play, seek and time always)
data-moey-speeds="1,1.5,2"The speeds the speed button goes through
.player-head · .player-cover · .player-title · .player-subAudio: a cover and titles above the bar
a.embed[data-moey-embed] (+ data-src, data-title)A cover that becomes the player when pressed (YouTube, Vimeo, any page)
.embed-play · .embed-title · .embed-note · .embed-4x3|1x1|9x16The cover's parts · shapes
.is-error · event moey:player-error · data-moey-error-textThe file can't be loaded or played: the bar says so ("Can't play this file", or your text) with a Try again button; screen readers hear it
Moey.player(el) · event moey:embed{ media, play(), pause() } · an embed was loaded