player.js
Drive a Momentable embed from your page: your own buttons, your own flow.
<iframe src="https://player.momentable.art/embed/c/met-women-painters" title="Momentable player" allow="fullscreen; screen-wake-lock"></iframe>
<script src="https://player.momentable.art/v1/player.js"></script>
<script>
const player = new Momentable.Player(document.querySelector('iframe'));
player.on('artworkchange', (a) => console.log(a.index, a.title));
player.next();
</script>
Methods
Each returns a promise of the player's state: play(), pause(), next(), previous(), goTo(index) (0-based), setSpeed('contemplative' | 'standard' | 'energized'), getState(), ready().
Events
ready, artworkchange, play, pause, ended, error. The SDK talks only to the iframe you give it, at its own origin; the embed answers only the page that frames it.
The element
Momentable's own sites, and partners who want the player in their page rather than in a frame, can place the <momentable-player> element. It keeps its styles to itself (Shadow DOM), so your page's styles do not reach it.
<script type="module" src="https://player.momentable.art/v1/momentable-player.js"></script>
<momentable-player src="https://player.momentable.art/c/met-women-painters.json" style="display:block;aspect-ratio:16/9"></momentable-player>
Attributes: speed, loop, controls="0", start. Methods and events are the same as above, called on the element itself (el.next(), el.addEventListener('artworkchange', …)). Collections shown by permission play only on the sites their owners approved. Add counts="1" to count plays, minutes and works for your site's report, with no cookies and nothing that names a visitor (the iframe embed counts on its own); dnt="1", Global Privacy Control or Do Not Track turn counting off.