Skip to content

Video.js with Peer5 for HLS integration




Video.js is a free and open source HTML5 video player that supports HLS.

The integration with Peer5 plugin is easy and involves just two lines of code. In addition to the player script, simply include the Peer5 client and the matching Peer5 VideoJS plugin based on your player version.

Peer5 client and plugins scripts

Add the following two scripts to the head of your player's page, based on your player version:

VideoJS v7.x

1
2
<script src="https://api.peer5.com/peer5.js?id=PEER5_CUSTOMER_ID"></script>
<script src="https://api.peer5.com/peer5.video-js7.plugin.js"></script>

VideoJS v6.x

1
2
<script src="https://api.peer5.com/peer5.js?id=PEER5_CUSTOMER_ID"></script>
<script src="https://api.peer5.com/peer5.videojs6.plugin.js"></script>

VideoJS v5.x

1
2
<script src="https://api.peer5.com/peer5.js?id=PEER5_CUSTOMER_ID"></script>
<script src="https://api.peer5.com/peer5.videojs5.plugin.js"></script>

Complete Example (VideoJS 7)

The following information needs to be filled according to your actual data:

  • PEER5_CUSTOMER_ID   your Peer5 Customer ID
  • MANIFEST_FILE   url to your .m3u8 file
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Video.js Demo</title>
    <!-- Peer5 scripts -->
    <script src="https://api.peer5.com/peer5.js?id=PEER5_CUSTOMER_ID"></script>
    <script src="https://api.peer5.com/peer5.video-js7.plugin.js"></script>

    <!-- Player scripts -->
    <link rel="stylesheet" href="https://vjs.zencdn.net/7.7.4/video-js.min.css">
    <script src="https://vjs.zencdn.net/7.7.4/video.min.js"></script>
</head>
<body>
    <video id="player" class="video-js vjs-default-skin" height="360" width="640" controls preload="none"></video>
    <script>
        var player = videojs('#player', {
          sources: [{
            src: 'MANIFEST_FILE',
            type: "application/x-mpegURL"
          }]
        });
    </script>
</body>
</html>

Visit the full Video.js docs here.

To test that you integrated with Peer5 correctly, and to see stats about what the Peer5 integration is doing, you can view the stats overlay.