How to Add Seekbar Thumbnail Preview Feature in an OTT Video Player

Innocrux
Innocrux Tech Blogs
4 min readMay 27, 2024
How to setup seekbar thumbail preview on player

Introduction

In the competitive world of Over-the-Top (OTT) video streaming services, user experience is paramount. One feature that enhances this experience is the seekbar preview. This functionality allows users to see a small preview of a video when they hover over or drag the seekbar, making it easier to navigate through the content. As an OTT solution provider, Innocrux understands the importance of delivering seamless and engaging experiences to users. This blog will delve into the use cases, challenges, implementation details, and additional considerations of adding a seekbar preview to an OTT video player.

Use Cases

The seekbar preview feature serves multiple purposes in an OTT video player. It not only helps improve the user interface but also plays a critical role in user engagement and content navigation. Here are some key use cases for incorporating a seekbar preview in your video player:

  1. Enhanced User Experience: Users can easily find specific scenes or parts of the video without blindly navigating.
  2. Efficient Content Browsing: Helps users quickly determine if a particular section of the video contains the content they are looking for.
  3. Engagement Boost: Users are more likely to engage with content when they can preview it, leading to longer watch times and higher satisfaction.

Challenges

Implementing a seekbar preview is not without its hurdles. There are several technical and user experience challenges that need to be addressed to ensure a smooth and efficient functionality. Here are the main challenges:

  1. Performance: Loading and displaying preview images without affecting the video playback performance.
  2. Bandwidth Usage: Minimizing the additional data required for preview images.
  3. Compatibility: Ensuring the feature works seamlessly across different devices and browsers.
  4. Accuracy: Synchronizing the preview images with the exact timestamps of the video.
  5. Dynamic Content: Handling dynamically generated content or live streams.
  6. Security: Protecting preview images from unauthorized access or manipulation.

How to Set Up Seekbar Preview

To implement a seekbar preview, you’ll need to generate sprite images and use them in conjunction with metadata to show previews at the correct times. Here’s a step-by-step guide on how to achieve this:

  1. Generating Sprite Images
    Sprite images are a collection of thumbnails from the video, arranged in a grid format. Each thumbnail represents a frame at a specific time interval. These sprite images are usually generated during the video processing stage using various video processing tools.
Seekbar Preview Sprite Image Thumbnail Example Output

2. Preparing Metadata
Metadata for the sprite image is essential to map the thumbnails to specific time intervals in the video. Here’s an example of how the metadata might look:

{
"frameWidth": 120,
"frameHeight": 67,
"totalCount": 100,
"durationPerFrame": 5,
"framesPerPageX": 10,
"framesPerPageY": 10
}

3. Implementing the Frontend
Using HTML, CSS, and JavaScript, you can overlay the seekbar preview on the video player.

HTML

<div class="video-container">
<video id="videoPlayer" src="input_video.mp4" controls></video>
<div id="seekbarPreview" class="seekbar-preview">
<img id="previewImage" src="sprite.png" />
</div>
</div>

CSS

.video-container {
position: relative;
width: 100%;
}

.seekbar-preview {
position: absolute;
display: none;
bottom: 50px; /* Adjust based on the height of your controls */
pointer-events: none;
}

.seekbar-preview img {
position: absolute;
width: auto;
height: auto;
}

Javascript

const video = document.getElementById('videoPlayer');
const seekbarPreview = document.getElementById('seekbarPreview');
const previewImage = document.getElementById('previewImage');

const metadata = {
frameWidth: 120,
frameHeight: 67,
totalCount: 100,
durationPerFrame: 5,
framesPerPageX: 10,
framesPerPageY: 10
};

video.addEventListener('mousemove', (e) => {
const rect = video.getBoundingClientRect();
const posX = e.clientX - rect.left;
const time = (posX / rect.width) * video.duration;

const frameIndex = Math.floor(time / metadata.durationPerFrame);
const col = frameIndex % metadata.framesPerPageX;
const row = Math.floor(frameIndex / metadata.framesPerPageX);

const offsetX = -col * metadata.frameWidth;
const offsetY = -row * metadata.frameHeight;

previewImage.style.left = `${offsetX}px`;
previewImage.style.top = `${offsetY}px`;

seekbarPreview.style.left = `${posX}px`;
seekbarPreview.style.display = 'block';
});

video.addEventListener('mouseleave', () => {
seekbarPreview.style.display = 'none';
});

Explanation of Key Parameters

frameWidth: The width of each thumbnail in the sprite image.
frameHeight: The height of each thumbnail.
totalCount: Total number of thumbnails in the sprite.
durationPerFrame: The duration each thumbnail represents.
framesPerPageX: Number of thumbnails per row in the sprite.
framesPerPageY: Number of thumbnails per column in the sprite.

Additional Considerations

  1. Dynamic Loading: For long videos, consider dynamically loading preview images as the user interacts with the seekbar to reduce initial loading times.
  2. Quality vs. Performance: Balancing the quality of preview images with performance considerations, especially on mobile devices with limited resources.
  3. Accessibility: Ensure the feature is accessible to all users, including those with disabilities, by providing alternative navigation options.
  4. A/B Testing: Test different implementations and configurations to optimize user engagement and satisfaction.
  5. Analytics: Monitor user interactions with the seekbar preview feature to gather insights and make data-driven improvements.
  6. Customization: Allow users to customize the seekbar preview feature, such as adjusting the size of thumbnails or enabling/disabling the feature.

Conclusion

Implementing a seekbar preview in an OTT video player significantly enhances user experience by allowing users to quickly navigate to specific parts of a video. While there are challenges related to performance, compatibility, dynamic content, security, and customization, Innocrux as an OTT solution provider, understands the importance of delivering seamless and engaging experiences to users.

By following the steps outlined above and considering additional factors, you can add this valuable functionality to your video player, ultimately improving user engagement and satisfaction. If you have any queries, contact the Innocrux OTT development team.

--

--

Innocrux
Innocrux Tech Blogs

Innocrux is the best video streaming solution provider, helping broadcasters build their own streaming platforms. To learn more visit https://www.innocrux.com/