2.0.27 • Published 5 months ago

cafe-video-player v2.0.27

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

cafe-video-player

✔ Playing static and vod videos

Installation

$ npm install --save cafe-video-player
$ yarn add cafe-video-player

Example

✔ To play vod, follow the example below:

import { VideoPlayerLibrary } from "cafe-video-player";

export default function HomePage() {
  const params = {
    type: "vod",
    id: "6623",
    banner: "image path", // (to display cover image from external url) optional
    subtitleUrl: "subtitle url", // (to display subtitle from external url) optional
    currentTime: 100, // (jump to second 100) optional
    onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
    subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
    /*
      subtitle example
      subtitles = [
        {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
        {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
      ]
    */
    
  };

  return (
    <div>
      <VideoPlayerLibrary params={params} />
    </div>
  );
}

Example

✔ To play static videos, follow the example below:

  • id corresponds to the video link, which must be base64 format
  • banner corresponds to the cover link, which must be base64 format
import { VideoPlayerLibrary } from "cafe-video-player";

export default function HomePage() {
  const params = {
    type: "static",
    id: "aHR0cHM6Ly9hYnJlaGFtcmFoaS5pci9vL3RXMHFONUQwWFB2R04wdGhJQUM1UUEv",
    banner: "image path", // (to display cover image from external url) optional
    onChangeCurrentTime: (currentTime: number) => console.log(currentTime), //optional, This function returns the current time value when clicking on the progress bar or the backward and forward buttons.
    subtitles = [{lang: "string", title: "string", url: "subtitle url"}] // optional
    /*
      subtitle example
      subtitles = [
        {lang: "fa", title: "فارسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b3aa9ce680b-sub_fa.srt"},
        {lang: "en", title: "انگلیسی", url: "https://hamrahi.cloud/subtitles/216-282790-6770242c63370b58ecce680d-sub_en.srt"},
      ]
    */
  };

  return (
    <div>
      <VideoPlayerLibrary params={params} />
    </div>
  );
}

Example

✔ To use the mini-player feature, follow the example below:

import { MiniPlayerLibrary } from "cafe-video-player";

export default function HomePage() {
  const params = {
    type: "vod",
    id: "6623",
    onClose: () => {},
  };

  return (
    <div>
      <MiniPlayerLibrary params={params} />
    </div>
  );
}

Example

✔ You can use bannerAlt props to set custom alt for video banner

import { VideoPlayerLibrary } from "cafe-video-player";

export default function HomePage() {
  const params = {
    id: "6623",
    type: "vod",
    bannerAlt: "alt for video banner",
  };

  return (
    <div>
      <VideoPlayerLibrary params={params} />
    </div>
  );
}

For the modals to work correctly, you need to add the following tag to the end of the body tag in the _document file.

<div id="dialog-react-root-videoPlayer" />

To display the player styles correctly, you must import the videoPlayerStyles.css file from the node _module folder inside the _app file according to the example below.

import "../node_modules/cafe-video-player/videoPlayerStyles.css";

To display the images correctly, you must put the following configuration in the next.config.ts file.

images: {
  remotePatterns: [
    {
      protocol: "https",
      hostname: "**"
    }
  ]
},
2.0.26

5 months ago

2.0.27

5 months ago

2.0.25

6 months ago

2.0.24

6 months ago

2.0.22

6 months ago

2.0.23

6 months ago

2.0.21

6 months ago

2.0.20

7 months ago

2.0.15

7 months ago

2.0.16

7 months ago

2.0.14

7 months ago

2.0.19

7 months ago

2.0.17

7 months ago

2.0.18

7 months ago

2.0.13

7 months ago

2.0.11

7 months ago

2.0.7

7 months ago

2.0.12

7 months ago

2.0.6

7 months ago

2.0.9

7 months ago

2.0.10

7 months ago

2.0.8

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.9.1

10 months ago

1.9.0

10 months ago

1.8.0

10 months ago

1.7.0

11 months ago

1.9.3

10 months ago

1.9.2

10 months ago

1.6.0

12 months ago

1.5.0

12 months ago

1.4.0

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.15

1 year ago

1.3.16

1 year ago

1.1.12

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.2.15

1 year ago

1.1.13

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago