1.0.47 • Published 9 months ago

@gl-solution/video-player v1.0.47

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

GL Solution VideoPlayer

Description

A VideoPlayer library for React and React Native which allows using the Player Component.

Installation

To install the library, use npm:

npm install @gl-solution/video-player

Prerequirements

WEB

If you are using library in NextJS project, please add webpack changes to the and of nextConfig variable in your next.config.js file

const webpack = require("webpack");

const nextConfig = {
  webpack: (config) => {
    config.plugins.push(
      new webpack.NormalModuleReplacementPlugin(/videoRN/, (resource) => {
        resource.request = "data:text/javascript,export default {}";
      })
    );
    return config;
  },
};
module.exports = nextConfig;

TVOS

If you are using library in ReactNative project for tvOS, please add next line to your Podfile and reinstall pods

pod 'react-native-video', :path => '../node_modules/react-native-video'

AndroidTV/FireTV

If you are using library in ReactNative project for AndroidTV or FireTV, please do next steps:

  1. Open android/app/build.gradle file and add next line to dependencies
implementation project(':react-native-video')
  1. Open MainApplication file. Add next import and add ReactVideoPackage to getPackages method
import com.brentvatne.react.ReactVideoPackage

...
add(ReactVideoPackage())
...
  1. Open android/settings.gradle file and add next lines
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')

Usage

Example of how to install VideoJS (https://videojs.com) in React and NextJS:

import { PlayerConstructor, IPlayerTypes } from "@gl-solution/video-player";

const VideoPlayer = () => {
  const Player = PlayerConstructor.init(IPlayerTypes.WEB);
  return (
    <div>
      // https://videojs.com/guides/options/
      <Player options={options} />
    </div>
  );
};

export default VideoPlayer;

Example of how to use library in React Native:

import { PlayerConstructor, IPlayerTypes } from "@gl-solution/video-player";

export default function ReactPlayer() {
  const Player = PlayerConstructor.init(IPlayerTypes.PHONE);
  return <Player />;
}

Adding Event Listeners

Example of how to add eventsListeners:

const eventsListeners = [
  {
    eventName: "play",
    callback: () => console.log("play event"),
  },
  {
    eventName: "pause",
    callback: () => console.log("pause event"),
  },
];
return <Player options={options} eventsListeners={eventsListeners} />;

Automatic Episode Playback

Example of setting up a list of episodes with automatic playback:

You should pass episodesPlaybackData properties to the Player component.

  • episodesList: Array with episode data (src for video and type of video).
  • isAutoPlayNext: Enables autoplay for the next episode (default is false).
  • episodeInd: Index of the episode from which to start playing (default is 0).
interface episodesPlaybackData {
  episodesList: {
    src: string;
    type: string;
  }[];
  isAutoPlayNext: boolean;
  episodeInd?: number;
}

const episodesPlaybackData = {
  isAutoPlayNext: true,
  episodesList: [
    {
      src: "src for video",
      type: "video type (e.g., application/x-mpegURL)",
    },
    {
      src: "src for video",
      type: "video type (e.g., application/x-mpegURL)",
    },
  ],
};

return <Player options={options} episodesPlaybackData={episodesPlaybackData} />;

Player Methods:

play() - Attempt to begin playback at the first opportunity.

GLPlayer.play();

pause() - Pause the video playback

GLPlayer.pause();
1.0.47

9 months ago

1.0.46

10 months ago

1.0.45

10 months ago

1.0.44

10 months ago

1.0.43

10 months ago

1.0.42

10 months ago

1.0.41

10 months ago

1.0.40

10 months ago

1.0.39

10 months ago

1.0.38

10 months ago

1.0.37

10 months ago

1.0.36

10 months ago

1.0.35

10 months ago

1.0.34

10 months ago

1.0.33

10 months ago

1.0.32

10 months ago

1.0.31

10 months ago

1.0.30

11 months ago

1.0.29

11 months ago

1.0.28

11 months ago

1.0.27

11 months ago

1.0.26

11 months ago

1.0.25

11 months ago

1.0.24

11 months ago

1.0.23

11 months ago

1.0.22

11 months ago

1.0.2105

11 months ago

1.0.2104

11 months ago

1.0.2103

11 months ago

1.0.2102

11 months ago

1.0.2101

11 months ago

1.0.2100

11 months ago

1.0.2099

11 months ago

1.0.2098

11 months ago

1.0.2093

11 months ago

1.0.2092

11 months ago

1.0.2091

11 months ago

1.0.2090

11 months ago

1.0.209

11 months ago

1.0.208

11 months ago

1.0.207

11 months ago

1.0.206

11 months ago

1.0.205

11 months ago

1.0.204

11 months ago

1.0.203

11 months ago

1.0.202

11 months ago

1.0.201

11 months ago

1.0.20

11 months ago

1.0.19

11 months ago

1.0.18

11 months ago

1.0.172

11 months ago

1.0.171

11 months ago

1.0.170

11 months ago

1.0.169

11 months ago

1.0.168

11 months ago

1.0.167

11 months ago

1.0.166

11 months ago

1.0.165

11 months ago

1.0.164

11 months ago

1.0.163

11 months ago

1.0.162

11 months ago

1.0.161

11 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago