Skip to main content

How to configure videojs player for HLS stream | VideoJs HLS player | play .m3u8 file using videojs

How to confider videojs player for HLS stream  | VideoJs HLS player | play .m3u8 file using videojs

To configure Video.js for HLS (HTTP Live Streaming) streams, you need to include the necessary plugins and set up the player with the appropriate options. Here's a step-by-step guide:

1. Include the Video.js library: Start by including the Video.js library in your HTML file. You can download it from the Video.js website or use a CDN. Add the following code within the `<head>` tag of your HTML file:

```html
<link href="https://vjs.zencdn.net/7.14.3/video-js.css" rel="stylesheet" />
<script src="https://vjs.zencdn.net/7.14.3/video.js"></script>
```

2. Include the HLS plugin: Video.js does not support HLS playback out of the box, so you'll need to include the videojs-contrib-hls plugin. Add the following code after the Video.js library script tag:

```html
    <script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script>
```

3. Create an HTML video element: Add a video element to your HTML markup with a unique ID. For example:

```html
<video id="example-video" width="auto" height="500" class="video-js vjs-default-skin" style="margin: 0 auto;" controls>

        <source src="https://example.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8"
                type="application/x-mpegURL">

    </video>
```

4. Enable HLS support: Tell Video.js to use the HLS plugin for HLS playback. Add the following code:

```javascript
    <script>

        var player = videojs('example-video');
        player.play();

    </script>
```

Replace `'YOUR_HLS_STREAM_URL'` with the actual URL of your HLS stream.

5. Customize player options (optional): You can customize various player options according to your needs. For example, you can change the controls, autoplay behavior, or add additional plugins. Refer to the Video.js documentation for more options.

6. Style the player (optional): Use CSS to style the player to match your desired look and feel. The Video.js CSS file you included in Step 1 provides some default styling, but you can override it or add your own styles.

That's it! With these steps, you should have Video.js configured to play HLS streams. Make sure to test your implementation with a supported HLS stream URL.

Videojs player is open source JavaScript library for handling HLS video streaming ( on dimand and live video streaming ) , it's very easy to configure on your code on any technology need only videojs library and initialise function for player initialisation see example for HTLM  


************************************start************************************ 
<!DOCTYPE html>

<html>
<head>

<title>Page Title</title>
 <link href="https://unpkg.com/video.js/dist/video-js.css" rel="stylesheet">

    <script src="https://unpkg.com/video.js/dist/video.js"></script>
    <script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script>

</head>
<body>

<div class="satel">
    <video id="example-video" width="auto" height="500" class="video-js vjs-default-skin" style="margin: 0 auto;" controls>

        <source src="https://example.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8"
                type="application/x-mpegURL">

    </video>

    <script>

        var player = videojs('example-video');
        player.play();

    </script>
</div>

</body>
</html>


************************************end************************************


If you like this blog so pls share and Write Comments about Your experience,
Thank You.


Comments

Popular posts from this blog

What is OOP (objects oriented programming) in C#

 What is OOP? in C# OOP is Object Oriented programming miens contain methods and data in objects it's called objects oriented programming(OOP) OOP Advantages Provides clear visibility and code for the programs easier to maintain, modify and debug Faster development easier and faster to execute create reusable code make your code neat and clean and easy to understand What is Class and objects in C# Class and object are the two main points of OOP (object oriented programming), when fruit is a class then Apple, Guava, Banana,  is object, when the individual objects are created they inherits all variables and method form the class, class is a template for the objects and object is instance of the class If you like this blog so pls share and  Write Comments  about Your experience, Thank You.

Make api in DotNet Core in 10sec | Create universal api for SQL server

Make API in Dot Net Core in 10sec | Create universal API for SQL server Universal API is great concept for app and angular developer need only connect to data base add table name and access table crud operation using API's  If you like this blog so pls share and  Write Comments  about Your experience, Thank You.

How to Optimize Your LinkedIn Profile as a Software Developer: Tips for Success

How to Optimize Your LinkedIn Profile as a Software Developer: Tips for Success To make your LinkedIn profile more attractive and discoverable as a software developer, you should focus on creating a compelling profile that showcases your skills, experience, and potential. Below are some specific strategies: 1. Professional Profile Picture Use a clear, professional photo where you look approachable and confident. A headshot with a neutral background works well. 2. Headline Your headline should be more than just your job title. Make it a powerful value proposition. Consider including: Your current role, tech stack, or specialization. Highlight key skills (e.g., "JavaScript | React | Node.js | Full-Stack Developer"). Optional: Include a personal tagline (e.g., "Building innovative web applications that solve real-world problems"). Example: "Full-Stack Developer | React, Node.js, Python | Passionate About Clean Code & Scalable Systems" 3. Summary (About Se...