Skip to main content

Video Player

HesedVid Video Player

The HesedVid Video Player is a core component of our video infrastructure, providing a professional, embeddable video experience that integrates seamlessly with your applications.

Overview

The HesedVid player is a fully-featured HTML5 video player designed for modern web applications. It provides:

  • Professional Video Experience: High-quality playback with adaptive bitrate streaming
  • Easy Integration: Simple iframe embedding for any web application
  • Customizable Interface: Branded player experience with your colors and logo
  • Analytics Integration: Built-in viewer engagement tracking and metrics
  • Cross-Platform Compatibility: Works across all modern browsers and devices
  • Accessibility: WCAG compliant with keyboard navigation and screen reader support

Architecture

Player Components

The HesedVid player consists of several key components:

┌─────────────────────────────────────┐
│ Player Container │
├─────────────────────────────────────┤
│ ┌─────────────────────────────────┐ │
│ │ Video Element │ │
│ │ (HLS/MP4/WebM Support) │ │
│ └─────────────────────────────────┘ │
│ ┌─────────────────────────────────┐ │
│ │ Control Interface │ │
│ │ (Play/Pause/Volume/Progress) │ │
│ └─────────────────────────────────┘ │
│ ┌─────────────────────────────────┐ │
│ │ Analytics Engine │ │
│ │ (Engagement Tracking) │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────┘

Technology Stack

  • Video Engine: HTML5 Video with HLS.js for adaptive streaming
  • UI Framework: Custom-built responsive interface
  • Analytics: Real-time engagement tracking
  • Communication: PostMessage API for parent-child interaction
  • Security: Origin verification and CSP compliance

Core Features

Adaptive Bitrate Streaming

The player automatically selects the optimal video quality based on:

  • Network Conditions: Bandwidth and connection stability
  • Device Capabilities: Screen resolution and processing power
  • User Preferences: Manual quality selection override
  • Content Availability: Available quality levels from the source

Responsive Design

The player automatically adapts to different screen sizes:

  • Desktop: Full-featured interface with all controls
  • Tablet: Touch-optimized controls and gestures
  • Mobile: Simplified interface with essential controls
  • TV/Large Screens: Optimized for remote control navigation

Analytics Integration

Built-in analytics track:

  • Viewer Engagement: Play time, completion rates, drop-off points
  • Quality Metrics: Resolution distribution, buffering events
  • Device Information: Browser, OS, screen resolution
  • Geographic Data: Country and region (anonymized)

Player URL Structure

Base URL Format

https://player.hesedvid.com/v1/private/{publicID}/master.m3u8
https://player.hesedvid.com/v1/public/{org_id}/{env_id}/{vid_id}/master.m3u8

Query Parameters

ParameterTypeDefaultDescription
autoplaybooleanfalseAuto-start video playback (true in iframes)
mutedbooleanfalseStart video muted (true in iframes to satisfy autoplay policies)
controlsbooleantrueShow native player controls
posterstring-URL to poster image shown before playback
qualitystringautoInitial quality selection. One of: auto, highest, lowest, or a height like 2160p, 1440p, 1080p, 720p, 480p, 360p, 240p, 144p (numbers without p also accepted). ABR remains enabled after startup.
signedstring-Signed URL for private videos (contains token)
tokenstring-Authentication token for private videos (alternative to signed)

Note: The player uses optimized defaults for low request overhead and fast starts.

Example URLs

Terminal window
# Private video with token
https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?token=abc123&autoplay=true&muted=true
# Public video
https://player.hesedvid.com/v1/public/org_123/env_456/vid_789/master.m3u8?autoplay=true&muted=true
# Force highest quality start (ABR still adapts afterward)
https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?autoplay=true&muted=true&quality=highest
# Force a specific starting quality (e.g., 1080p)
https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?autoplay=true&muted=true&quality=1080p
# Start at the lowest quality (fastest first frame)
https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?autoplay=true&muted=true&quality=lowest

Performance Notes

The player minimizes startup requests and uses tuned defaults for fast playback. Use high=1 to override the default low-variance startup and begin at the highest rendition when you know the viewer has sufficient bandwidth.

Integration Patterns

Iframe Embedding

The most common integration method:

<iframe
src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8"
width="800"
height="450"
frameborder="0"
allowfullscreen>
</iframe>

Advantages:

  • Simple implementation
  • Isolated from parent page CSS/JS
  • Automatic security sandboxing
  • Cross-domain compatibility

Responsive Container

Always use responsive containers for optimal viewing:

.video-container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

Communication API

PostMessage Events

The player communicates with the parent page through PostMessage:

Player → Parent Events

EventDataDescription
playerReady{type: 'playerReady'}Player is initialized and ready
play{type: 'play'}Playback started
pause{type: 'pause'}Playback paused
ended{type: 'ended'}Playback completed
timeUpdate{type: 'timeUpdate', currentTime: number}Current playback time
volumeChange{type: 'volumeChange', volume: number}Volume level changed
error{type: 'error', error: string}Player error occurred

Parent → Player Commands

CommandDataDescription
play{type: 'play'}Start playback
pause{type: 'pause'}Pause playback
setVolume{type: 'setVolume', volume: number}Set volume (0-1)
seekTo{type: 'seekTo', time: number}Seek to specific time
mute{type: 'mute'}Mute audio
unmute{type: 'unmute'}Unmute audio

Event Handling Example

// Listen for player events
window.addEventListener('message', function(event) {
// Verify origin for security
if (event.origin !== 'https://player.hesedvid.com') {
return;
}
const data = event.data;
switch (data.type) {
case 'playerReady':
console.log('Player ready');
break;
case 'play':
// Track play event
analytics.track('video_play', {
video_id: data.videoId,
timestamp: Date.now()
});
break;
case 'timeUpdate':
// Update progress bar
updateProgressBar(data.currentTime, data.duration);
break;
case 'ended':
// Track completion
analytics.track('video_complete', {
video_id: data.videoId,
duration: data.duration
});
break;
}
});
// Send commands to player
function controlPlayer(command, data = {}) {
const iframe = document.getElementById('player');
iframe.contentWindow.postMessage({
type: command,
...data
}, 'https://player.hesedvid.com');
}

Theming and Customization

Theme Options

Light Theme

<iframe src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?theme=light"></iframe>

Dark Theme

<iframe src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?theme=dark"></iframe>

Auto Theme (Default)

<iframe src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?theme=auto"></iframe>

The auto theme automatically switches between light and dark based on the user’s system preference.

Branding Control

<!-- Show HesedVid branding (default) -->
<iframe src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?branding=true"></iframe>
<!-- Hide branding for white-label experience -->
<iframe src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?branding=false"></iframe>

Security Considerations

Content Security Policy (CSP)

Configure your CSP headers to allow the HesedVid player:

<meta http-equiv="Content-Security-Policy"
content="frame-src https://player.hesedvid.com;">

Origin Verification

Always verify message origins when using PostMessage:

window.addEventListener('message', function(event) {
// Only accept messages from HesedVid player
if (event.origin !== 'https://player.hesedvid.com') {
return;
}
// Process message safely
handlePlayerMessage(event.data);
});

HTTPS Requirement

The player requires HTTPS for security:

  • https://player.hesedvid.com - Secure connection
  • http://player.hesedvid.com - Not supported

Performance Optimization

Lazy Loading

Load the player only when it’s about to be viewed:

const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const iframe = entry.target;
iframe.src = iframe.dataset.src;
observer.unobserve(iframe);
}
});
});
document.querySelectorAll('[data-src]').forEach(iframe => {
observer.observe(iframe);
});

Preloading

Preload player resources for better performance:

<link rel="preconnect" href="https://player.hesedvid.com">
<link rel="dns-prefetch" href="https://player.hesedvid.com">

Analytics and Metrics

Built-in Analytics

The player automatically tracks:

  • Engagement Metrics: Play time, completion rates, drop-off points
  • Quality Metrics: Resolution distribution, buffering events
  • Device Metrics: Browser, OS, screen resolution
  • Performance Metrics: Load times, error rates

Custom Analytics Integration

window.addEventListener('message', function(event) {
if (event.origin !== 'https://player.hesedvid.com') return;
const data = event.data;
// Send to your analytics service
switch (data.type) {
case 'play':
gtag('event', 'video_play', {
video_id: data.videoId,
video_title: data.videoTitle
});
break;
case 'timeUpdate':
// Track progress milestones
if (data.currentTime > 0 && data.currentTime % 30 === 0) {
gtag('event', 'video_progress', {
video_id: data.videoId,
progress: Math.round(data.currentTime / data.duration * 100)
});
}
break;
}
});

Error Handling

Common Error Types

Error TypeDescriptionSolution
VIDEO_NOT_FOUNDVideo ID doesn’t existVerify video ID is correct
ACCESS_DENIEDVideo is privateUse signed URL or make video public
NETWORK_ERRORConnection issuesCheck network connectivity
FORMAT_ERRORUnsupported formatVerify video format compatibility

Error Handling Example

window.addEventListener('message', function(event) {
if (event.origin !== 'https://player.hesedvid.com') return;
if (event.data.type === 'error') {
const error = event.data.error;
switch (error.type) {
case 'VIDEO_NOT_FOUND':
showErrorMessage('Video not found. Please check the video ID.');
break;
case 'ACCESS_DENIED':
showErrorMessage('This video is private. Please contact the owner.');
break;
case 'NETWORK_ERROR':
showErrorMessage('Network error. Please check your connection.');
break;
default:
showErrorMessage('An error occurred while loading the video.');
}
}
});

Best Practices

Responsive Implementation

/* Always use responsive containers */
.video-container {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}

Accessibility

<!-- Include proper accessibility attributes -->
<iframe
src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8"
title="Video: My Video Title"
aria-label="Video player for My Video Title"
allowfullscreen>
</iframe>

Performance

// Use lazy loading for better performance
const lazyPlayer = document.createElement('iframe');
lazyPlayer.dataset.src = 'https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8';
lazyPlayer.style.width = '100%';
lazyPlayer.style.height = '450px';
lazyPlayer.frameBorder = '0';
lazyPlayer.allowFullscreen = true;
// Load when visible
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.src = entry.target.dataset.src;
observer.unobserve(entry.target);
}
});
});
observer.observe(lazyPlayer);

Troubleshooting

Common Issues

IssueCauseSolution
Player not loadingInvalid video IDVerify video exists and is public
Controls not workingCSP blockingAdd https://player.hesedvid.com to frame-src
Events not firingOrigin mismatchVerify PostMessage origin check
Responsive issuesFixed dimensionsUse responsive container with padding-bottom
Audio not workingBrowser autoplay policyUser must interact with page first

Debug Mode

Enable debug logging for troubleshooting:

<iframe src="https://player.hesedvid.com/v1/private/pubvid_AbCdEf/master.m3u8?debug=true"></iframe>

This will log additional information to the browser console.

Rate Limits

OperationLimitWindow
Player loads1000 requests1 hour
Event messages10,000 messages1 hour
Analytics events50,000 events1 hour

Tip

The HesedVid player automatically handles video quality selection and adaptive bitrate streaming for optimal viewing experience across all devices.

Caution

Always verify the message origin when using the PostMessage API to prevent security vulnerabilities.