@bayesgg/bayes-web-player-js
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

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;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.73latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.73
0.1.60
0.1.40
0.1.30
0.1.20

Package Sidebar

Install

npm i @bayesgg/bayes-web-player-js

Weekly Downloads

3

Version

0.1.7

License

See LICENSE.txt for license

Unpacked Size

699 kB

Total Files

14

Last publish

Collaborators

  • account.bayesgg.builds
  • shahid.hassan
  • eren-bayes