Skip to content

Shaka Player with Peer5 for DASH integration

Shaka Player is a free and open source HTML5 video player that supports playing MPEG-DASH without any plugin. In addition Shaka plays HLS video on the Chromecast.

The integration with Peer5 plugin is as easy as it can get.

Peer5 client and player scripts

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

Complete Example

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

  • PEER5_CUSTOMER_ID   your Peer5 Customer ID
  • MANIFEST_FILE   url to your .mpd file (or .m3u8 on the Chromecast)
 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
26
27
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Peer5 Demo</title>
    <!-- peer5 client & plugin-->
    <script src="//api.peer5.com/peer5.js?id=PEER5_CUSTOMER_ID"></script>
    <script src="//api.peer5.com/peer5.shakaplayer.plugin.js"></script>
    <!-- shakaplayer script-->
    <script src="//cdnjs.cloudflare.com/ajax/libs/shaka-player/2.0.1/shaka-player.compiled.js"></script>
  </head>
  <body>
    <video id="video" width="640" controls autoplay></video>
    <script>
      var video = document.getElementById('video');
      window.shaka.polyfill.installAll();

      if (!shaka.Player.isBrowserSupported()) {
          parentEl.innerHTML = 'Shaka player is not supported in this browser';
      }
      else {
          var player = new shaka.Player(video);
          player.load("MANIFEST_FILE");
      }
    </script>
  </body>
</html>

Visit here for the full Shaka Player docs.

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.