Products
Products
Video Hosting
Upload and manage your videos in a centralized video library.
Image Hosting
Upload and manage all your images in a centralized library.
Galleries
Choose from 100+templates to showcase your media in style.
Video Messaging
Record, and send personalized video messages.
CincoTube
Create your own community video hub your team, students or fans.
Pages
Create dedicated webpages to share your videos and images.
Live
Create dedicated webpages to share your videos and images.
For Developers
Video API
Build a unique video experience.
DeepUploader
Collect and store user content from anywhere with our file uploader.
Solutions
Solutions
Enterprise
Supercharge your business with secure, internal communication.
Townhall
Webinars
Team Collaboration
Learning & Development
Creative Professionals
Get creative with a built in-suite of editing and marketing tools.
eCommerce
Boost sales with interactive video and easy-embedding.
Townhall
Webinars
Team Collaboration
Learning & Development
eLearning & Training
Host and share course materials in a centralized portal.
Sales & Marketing
Attract, engage and convert with interactive tools and analytics.
"Cincopa helped my Enterprise organization collaborate better through video."
Book a Demo
Resources
Resources
Blog
Learn about the latest industry trends, tips & tricks.
Help Centre
Get access to help articles FAQs, and all things Cincopa.
Partners
Check out our valued list of partners.
Product Updates
Stay up-to-date with our latest greatest features.
Ebooks, Guides & More
Customer Stories
Hear how we've helped businesses succeed.
Boost Campaign Performance Through Video
Discover how to boost your next campaign by using video.
Download Now
Pricing
Watch a Demo
Demo
Login
Start Free Trial
Shaka Player is an open-source JavaScript library for adaptive video streaming, designed to deliver high-quality video across a variety of devices and browsers. Built with support for MPEG-DASH and HLS streaming protocols, Shaka Player offers flexibility and customization options for controlling playback, subtitles, and streaming quality. Setting Up Shaka Player Step 1: Installing Shaka Player To start using Shaka Player, include the required JavaScript file in your HTML page. You can either host the library locally or use a CDN. Explanation: src='https://cdn.jsdelivr.net/... : References a specific version ( 3.0.0 ) of the Shaka Player hosted on the jsDelivr CDN, ensuring consistent behavior and caching benefits. shaka-player.compiled.js : Provides a production-ready, minified build of Shaka Player with all core features bundled into a single script. Step 2: Initialize Shaka Player Once the library is loaded, you can initialize Shaka Player on a video element. The following example demonstrates how to initialize the player and load a media stream.
Explanation:
: Defines a standard HTML5 video element with playback controls, dimensions set to 640×360, and an assigned id for scripting reference. new shaka.Player(...) : Instantiates a Shaka Player instance, attaching it to the video element to enable advanced streaming features. .load('https://path-to-your-manifest.mpd') : Loads a DASH manifest (MPD file) to provide metadata for adaptive streaming, including available bitrates, segments, and timing information. .then(...) / .catch(...) : Implements a promise-based success and error handler. Advanced Playback Features Adaptive Bitrate Streaming (ABR) Shaka Player is designed to automatically select the appropriate video quality based on the user's network conditions. This dynamic bitrate switching ensures the video plays smoothly, even in fluctuating network environments. Shaka handles ABR internally by parsing the available video qualities from the manifest and adjusting the quality in real-time. // Enable ABR in Shaka Player (default behavior) player.configure('abr.enabled', true); Explanation : player.configure('abr.enabled', true); : Enables Adaptive Bitrate (ABR) streaming in Shaka Player, allowing the player to automatically switch between quality levels based on current network conditions. abr.enabled : A configuration flag in Shaka Player that controls whether ABR is active. When set to true , the player monitors bandwidth and buffer health in real-time to dynamically select the most appropriate video stream. player.configure(...) : Applies configuration settings to the Shaka Player instance. While ABR is enabled by default, explicitly setting it can be useful for clarity or conditional feature toggling. Shaka Player also supports manual quality selection by allowing users to switch between available video qualities. This can be useful in scenarios where users want to override automatic quality selection. Changing Quality Manually If you want to allow users to select video quality manually, you can expose the available qualities and use the selectAdaptation method to set the preferred quality. const availableQualities = player.getQualityLevels(); const manualQuality = availableQualities[1]; // Select the second quality level player.selectAdaptation(manualQuality); Explanation: getQualityLevels() : Retrieves the list of available video qualities. The selectAdaptation() method is used to set the selected quality level. Subtitle and Closed Captioning Control Adding Subtitles Shaka Player supports multiple subtitle formats, such as WebVTT and TTML, allowing for easy integration of captions. You can add subtitles to the player using the addTextTrack method. player.addTextTrack('https://path-to-subtitles.vtt', 'en', 'subtitles'); Explanation: First parameter ( 'https://path-to-subtitles.vtt' ): URL to the WebVTT file containing subtitle or caption data. Second parameter ( 'en' ): Specifies the language of the text track using a standard language code (English). Third parameter ( 'subtitles' ): Defines the kind of text track being added, typically 'subtitles' or 'captions' to inform the player how to handle the text data. Toggling Subtitle Visibility Shaka Player also offers the ability to toggle subtitles on and off. This can be implemented by adding a button to the UI. document.getElementById('toggleSubtitles').addEventListener('click', function() { const textTracks = player.getTextTracks(); textTracks.forEach(track => { track.mode = track.mode === 'showing' ? 'disabled' : 'showing'; }); }); Explanation: player.getTextTracks() : Retrieves an array of all text tracks currently loaded in the player. track.mode : Controls the display state of each text track. Event listener on 'click' : Adds interactive functionality to toggle subtitle visibility on user input. document.getElementById('toggleSubtitles').addEventListener('click', ...) : Toggles the visibility of all text tracks (such as subtitles or captions) in the video player when the button with ID 'toggleSubtitles' is clicked. Live Streaming Control Live Stream Event Handling Shaka Player provides robust support for live streaming scenarios. It can handle the real-time buffering and segment loading required for live video streams. To optimize the playback of live content, Shaka allows monitoring and handling various live stream events, such as buffer updates and end-of-stream signals. player.addEventListener('buffering', function(event) { if (event.buffering) { console.log('Buffering...'); } else { console.log('Buffering complete!'); } }); player.addEventListener('endOfStream', function() { console.log('Stream ended.'); }); Explanation: player.addEventListener('buffering', function(event) { ... }) : Listens for buffering state changes on the video player and logs the current buffering status. When event.buffering is true , the player is loading data and playback may pause; the message 'Buffering...' is logged. When event.buffering is false , buffering has finished and playback can resume; the message 'Buffering complete!' is logged. player.addEventListener('endOfStream', function() { ... }) : Listens for the end of the media stream and logs 'Stream ended.' once playback reaches the stream’s conclusion. Live Stream Latency Optimization In live streaming, reducing latency is critical. Shaka Player provides tools for optimizing live stream latency by adjusting the segment duration and buffer size. The following code snippet demonstrates how to adjust the buffer for a low-latency live stream. player.configure('streaming.bufferingGoal', 15); // Set buffering goal to 15 seconds player.configure('streaming.latency', 'low'); // Optimize for low latency Explanation: player.configure('streaming.bufferingGoal', 15) : Sets the player’s buffering goal to 15 seconds for specifying the desired amount of video data (in seconds) to pre-buffer ahead of playback to reduce interruptions. player.configure('streaming.latency', 'low') : Optimizes the streaming configuration for low latency to prioritize minimal delay between live content and playback to improve real-time viewing experiences. Error Handling and Debugging in Shaka Player Handling errors in streaming is essential for a seamless experience. Shaka Player offers robust error management features, allowing you to catch and log errors that occur during playback, such as network issues or unsupported formats. player.addEventListener('error', function(event) { const error = player.getError(); console.error('Shaka Player Error:', error.message); }); Explanation: player.addEventListener('error', function(event) { ... }) : Attaches an event listener to handle errors emitted by Shaka Player during playback or streaming. player.getError() : Retrieves detailed error information from the player instance. console.error('Shaka Player Error:', error.message) : Logs the error message to the console to aid in debugging and error diagnosis.