Step 1: Create a div with an id, wherever you want to add the video player, and name it as you wish.
<div id="player"></div>
Step 2: Pass the attributes: data-src (custom video url) and data-media-type (custom video media type)to the div you created in Step 1, like the example below.
Note : If the video type is hls then pass the data-media-type as "hls", otherwise you need to pass it as "mp4" (Currently Splay supports only "hls" and "mp4")
Example :
<div
id="player"
data-src="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
data-media-type="hls"
></div>
https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.css
<link
rel="stylesheet"
href="https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.css"
/>
https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.js
<script src="https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.js"></script>
Step 7: To add functionality to the video player, add the following code to your main JS file or under 'script' tag inside the body element of HTML.
const id = "b8579cc0-9d40-43ef-8636-a32976e84899";
const token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMmI2NDZkNWUtYzMxZC00YTMxLWFmM2UtMjYxYTRlZWY0MDYyIiwiaXNzIjoic2thcmEtcGxheWVyIiwic3ViIjoiYjg1NzljYzAtOWQ0MC00M2VmLTg2MzYtYTMyOTc2ZTg0ODk5IiwiYXVkIjpbInBsYXllci1kZXYiXSwibmJmIjoxNzA4NDIxNjExLCJpYXQiOjE3MDg0MjE2MTF9.VTkmc4KiFtO1xwQTb_dP3xjuErzYr1SSUJU4fgVpxPg";
const player = new window.SkaraPlayer("player", id, token);
player.start();
<body>
<script>
const id = "b8579cc0-9d40-43ef-8636-a32976e84899";
const token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMmI2NDZkNWUtYzMxZC00YTMxLWFmM2UtMjYxYTRlZWY0MDYyIiwiaXNzIjoic2thcmEtcGxheWVyIiwic3ViIjoiYjg1NzljYzAtOWQ0MC00M2VmLTg2MzYtYTMyOTc2ZTg0ODk5IiwiYXVkIjpbInBsYXllci1kZXYiXSwibmJmIjoxNzA4NDIxNjExLCJpYXQiOjE3MDg0MjE2MTF9.VTkmc4KiFtO1xwQTb_dP3xjuErzYr1SSUJU4fgVpxPg";
const player = new window.SkaraPlayer("player", id, token);
player.start();
</script>
</body>
Note : SkaraPlayer required parameters are: 'id' and 'token', which are available on the Splay dashboard.
<button id="play-btn">play</button>
<button id="pause-btn">puase</button>
Step 9 : To add custom play and pause button functionality, use the following in JS file or HTML script tag created in Step 7
const playBtn = document.querySelector("#play-btn");
playBtn.addEventListener("click", () => player.play());
const pauseBtn = document.querySelector("#pause-btn");
pauseBtn.addEventListener("click", () => player.pause());
<html>
<head>
<link
rel="stylesheet"
href="https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.css"
/>
</head>
<body>
<div
id="player"
data-src="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
data-media-type="hls"
></div>
<button id="play-btn">play</button>
<button id="pause-btn">puase</button>
<script src="https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.js"></script>
<script>
const id = "b8579cc0-9d40-43ef-8636-a32976e84899";
const token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMmI2NDZkNWUtYzMxZC00YTMxLWFmM2UtMjYxYTRlZWY0MDYyIiwiaXNzIjoic2thcmEtcGxheWVyIiwic3ViIjoiYjg1NzljYzAtOWQ0MC00M2VmLTg2MzYtYTMyOTc2ZTg0ODk5IiwiYXVkIjpbInBsYXllci1kZXYiXSwibmJmIjoxNzA4NDIxNjExLCJpYXQiOjE3MDg0MjE2MTF9.VTkmc4KiFtO1xwQTb_dP3xjuErzYr1SSUJU4fgVpxPg";
const player = new window.SkaraPlayer("player", id, token);
player.start();
const playBtn = document.querySelector("#play-btn");
playBtn.addEventListener("click", () => player.play());
const pauseBtn = document.querySelector("#pause-btn");
pauseBtn.addEventListener("click", () => player.pause());
</script>
</body>
</html>
index.html ->
<html>
<head>
<link
rel="stylesheet"
href="https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.css"
/>
</head>
<body>
<div
id="player"
data-src="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
data-media-type="hls"
></div>
<button id="play-btn">play</button>
<button id="pause-btn">puase</button>
<script src="https://splay-plugin-web.s3.ap-south-1.amazonaws.com/production/v0.1.47/index.js"></script>
<script src="index.js"></script>
</body>
</html>
index.js ->
const id = "b8579cc0-9d40-43ef-8636-a32976e84899";
const token =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMmI2NDZkNWUtYzMxZC00YTMxLWFmM2UtMjYxYTRlZWY0MDYyIiwiaXNzIjoic2thcmEtcGxheWVyIiwic3ViIjoiYjg1NzljYzAtOWQ0MC00M2VmLTg2MzYtYTMyOTc2ZTg0ODk5IiwiYXVkIjpbInBsYXllci1kZXYiXSwibmJmIjoxNzA4NDIxNjExLCJpYXQiOjE3MDg0MjE2MTF9.VTkmc4KiFtO1xwQTb_dP3xjuErzYr1SSUJU4fgVpxPg";
const player = new window.SkaraPlayer("player", id, token);
player.start();
const playBtn = document.querySelector("#play-btn");
playBtn.addEventListener("click", () => player.play());
const pauseBtn = document.querySelector("#pause-btn");
pauseBtn.addEventListener("click", () => player.pause());
``;