Analytics plugin

0.8 KB gzip
@tomato-player/plugin-analytics

Emits vendor-neutral playback analytics: view start with startup time, play, pause, seek, quartiles, rebuffering and heartbeat watch time. Send the events to any backend.

Open the analytics demo to watch the events stream in.

Install

npm i @tomato-player/plugin-analytics

Usage

player.ts — ts
import { createPlayer } from '@tomato-player/core';
import { minimal } from '@tomato-player/skin-minimal';
import { analytics } from '@tomato-player/plugin-analytics';
​
createPlayer('#player', {
src: 'movie.mp4',
skin: minimal(),
plugins: [analytics({ heartbeat: 10000, onEvent: (e) => navigator.sendBeacon('/qoe', JSON.stringify(e)) })],
});

Options

OptionTypeDescription
onEvent(event) => voidCalled for every analytics event.
heartbeatnumberMilliseconds between watch-time heartbeats.

Other plugins

HotkeysKeyboard shortcuts with familiar defaults, fully remappable.
GesturesDouble-tap to seek on touch, with visual feedback.
ChaptersChapters from an array or WebVTT, with seek-bar markers.
ThumbnailsSeek-bar preview thumbnails from WebVTT sprite sheets.
PlaylistNext and previous, auto-advance and loop.
Media SessionLock-screen controls, artwork and hardware media keys.
PersistRemember volume, speed, captions and resume position.