@bayesgg/bayes-web-player-js
v0.1.7
Published
JavaScript library for Bayes Web Player component
Downloads
193
Keywords
Readme
Bayes Web Player
What is Bayes Web Player?
Bayes Web Player is a lightweight, feature-rich frontend library that is developed in-house specifically to embed video streams from Bayes TV on your site. Offering an effortless integration, the player is written using TypeScript without any frontend framework restrictions and will be made available as an NPM package as well as via CDN. For more information refer to official documentation here.
Features
Playback Features
- Autoplay ON/OFF as required.
- Detachable player.
- Comprehensive API for stream playback control, volume control, UI control etc.
User Interface
- Fullscreen.
- Volume controls.
- Custom error message.
- Custom styling.
- Thumbnail.
- Watermarking.
Integration
Installation
You can install the library and the default stylesheets for the Bayes Web Player via CDN and as an NPM package.
npm i --save @bayesgg/bayes-web-player-js
Usage
The Bayes Web Player offers an easy to integrate interface which can be either imported (NPM) or referred to via the global instance. You can find minimal examples given below.
JS integration via CDN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- CDN import for the minified JS files of the Bayes Web Player -->
<script src="bwp.js" crossorigin></script>
<!-- CDN import for the minified stylesheet of the Bayes Web Player -->
<link rel="stylesheet" href="css/bwp.css" />
<script>
const player = new bwp.Player(
/**
* Playlist URL fetched via Bayes TV
* */
"insert-playlist-url-here",
/**
* Container ID where the player will be embedded
* */
"root",
/**
* Options for the player to be initialized. You can find a comprehensive
* list of available options provided later in the documentation
**/
{
autoplay: true,
}
);
// Initialise and play the video.
player.init();
player.play();
</script>
<title>Bayes Web Player Demo! :)</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
React Integration via NPM
import { useEffect, useRef } from "react";
import BayesWebPlayer from "@bayesgg/bayes-web-player-js";
/**
* Import the default stylesheet from Bayes Web Player
*/
import "@bayesgg/bayes-web-player-js/dist/css/bwp.css";
function Stream() {
const ref = useRef();
useEffect(() => {
/**
* Instantiate player with the container ref
*/
const player = new BayesWebPlayer(
/**
* Playlist URL fetched via Bayes TV
*/
"insert-playlist-url-here",
ref.current,
{
autoplay: true,
muted: true,
}
);
player.init();
player.play();
/**
* Make sure the player is destroyed on component unmount
*/
return () => {
player.destroy();
};
}, []);
return <div ref={ref} />;
}
export default Stream;