Annotations are interactive overlays that appear on the video at specific times. They can be used to highlight important information, provide additional context, or create clickable call-to-actions.
Add annotations to your video by including them in the source configuration. Annotations appear during playback at their configured times.
const mediaSource = {
id: 'annotations-demo',
src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
type: 'application/x-mpegURL',
title: 'Video with Annotations',
annotations: [
{
src: '/annotations.json', // URL to JSON annotation file
label: 'Example', // Display name
srclang: 'en', // Language code
type: 'json', // Specify JSON format
default: true // Set as default annotation track
}
]
};
player.setup(mediaSource);
Support multiple languages by providing annotation tracks in different languages. Users can switch between language tracks using the annotations menu. Only the track marked with default: true will be active initially.
const mediaSource = {
id: 'multiple-annotations-demo',
src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
type: 'application/x-mpegURL',
title: 'Video with Multiple Annotation Tracks',
annotations: [
{
src: '/annotations.json',
label: 'English', // English annotations
srclang: 'en',
type: 'json',
default: true
},
{
src: '/annotations-es.json',
label: 'Español', // Spanish annotations
srclang: 'es',
type: 'json'
}
]
};
player.setup(mediaSource);
Annotations appear at specific start times and disappear at end times, allowing you to show information only when relevant.
Position annotations anywhere on the video using top and left percentages (0-100). This allows precise placement relative to video content.
Each annotation can have its own unique styling defined in the JSON file. Customize font size, text color, background color, and dimensions individually for each annotation to match your brand or design.
Include URLs in annotation text to create clickable links that open in new tabs.
Annotations use JSON format with time ranges, positioning, and styling properties.
[
{
"type": 3,
"text": "This is an example annotation",
"title": "",
"starts": {
"hh": 0,
"mm": 0,
"ss": 5,
"ms": 0
},
"ends": {
"hh": 0,
"mm": 0,
"ss": 15,
"ms": 0
},
"top": 10,
"left": 50,
"width": 200,
"height": 40,
"fontsize": "12px",
"fontcolor": "FFFFFF",
"background": "2196F3"
},
{
"type": 3,
"text": "Check out http://example.com for more info",
"title": "",
"starts": {
"hh": 0,
"mm": 1,
"ss": 0,
"ms": 0
},
"ends": {
"hh": 0,
"mm": 1,
"ss": 15,
"ms": 0
},
"top": 70,
"left": 20,
"width": 250,
"height": 40,
"fontsize": "12px",
"fontcolor": "FFFFFF",
"background": "4CAF50"
}
]
starts - Start time object with hh, mm, ss, msends - End time object with the same structuretop - Vertical position as percentage (0-100)left - Horizontal position as percentage (0-100)width - Width in pixelsheight - Height in pixelsfontsize - Font size (e.g., "12px")fontcolor - Text color as hex without # (e.g., "FFFFFF")background - Background color as hex without # (e.g., "2196F3")type - Annotation type (3 for text annotations)text - Annotation text content (can include URLs)title - Optional titleControl annotation functionality with player options:
const options = {
showAnnotations: true // Show annotations button (default: true)
};
player.setup(mediaSource, options);
showAnnotations - Show/hide the annotations button in the player controls (default: true)