Skip to content

Softvelum/webrtc-player-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebRTC Player Lib

WebRTC Player library is a wrapper over Media Server independent WebRTC player that allows for direct usage within a web browser.

Getting Started

Add library to HTML

<script defer="defer" src="webrtc-player-lib-0.12.0.min.js"></script>

Usage

const video = document.querySelector('video');
const player = new WebRTCPlayer({
  video: video,
  type: 'whep',
  statsTypeFilter: '^candidate-*|^inbound-rtp'
});
player.load(new URL('https://127.0.0.1:8443/live/whep'));

Full example

<!DOCTYPE html>
<html>
  <head>
    <script defer="defer" src="webrtc-player-lib-0.12.0.min.js"></script>
  </head>
  <body>
    <script type="text/javascript">
      document.addEventListener("DOMContentLoaded", 
      const video = document.querySelector('video');
      const player = new WebRTCPlayer({
        video: video,
        type: 'whep',
        statsTypeFilter: '^candidate-*|^inbound-rtp'
      });
      player.load(new URL('https://127.0.0.1:8443/live/whep'));
      });
    </script>
  </body>
</html>

Related documentation