# react-fb-player

> A facebook video player implementation for react

Latest version **1.1.1** (published 2018-04-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-fb-player
pnpm add react-fb-player
yarn add react-fb-player
bun add react-fb-player
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2018-04-05 |
| First published | 2018-03-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Santiago D'Antuoni |
| Maintainers | alemesa, sdantuoni |
| Keywords | react, fb, facebook, player, video, react-component, embed |

## Links

- npm: https://www.npmjs.com/package/react-fb-player
- Repository: https://github.com/sdantuoni/react-fb-player
- Homepage: https://github.com/sdantuoni/react-fb-player#readme
- Issues: https://github.com/sdantuoni/react-fb-player/issues
- npm.io page: https://npm.io/package/react-fb-player

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2018-04-05
- 1.1.0 — 2018-04-03
- 1.0.9 — 2018-04-03
- 1.0.8 — 2018-04-03
- 1.0.7 — 2018-04-02
- 1.0.6 — 2018-03-26
- 1.0.5 — 2018-03-21
- 1.0.4 — 2018-03-21
- 1.0.3 — 2018-03-21
- 1.0.2 — 2018-03-21
- 1.0.1 — 2018-03-21
- 1.0.0 — 2018-03-21

## README

react-fb-player
=============================

This is a modified fork of [react-youtube](https://github.com/fmedinac/react-facebook-player) with new features

## Installation

```
$ npm install react-fb-player --save
```

## Usage

```js
const FacebookPlayer = require('react-fb-player');

<FacebookPlayer
  appId={ string }    // (required) Your Facebook App ID. Ref: http://bit.ly/1GNA0AN
  videoId={ string }  // (required) Video´s ID Ref: http://bit.ly/1ysgVu4
  id={ string }   // Element ID. Required if you wanna use more than one video in the same page.
  className={ string }   // Element class.
  allowfullscreen={ boolean }
  autoplay={ boolean }
  width={ number }
  showText={ boolean }
  showCaptions={ boolean }
  onReady={ function } // Returns a player object to be used for controlling
  onStartedPlaying={ function }
  onPaused={ function }
  onFinishedPlaying={ function }
  onStartedBuffering={ function }
  onFinishedBuffering={ function }
  onError={ function }
  />
```

You can use onReady() to assign the player to a state and then control it (http://bit.ly/29Oxmgm).

```js
import React from 'react';
import FacebookPlayer from 'react-fb-player';

export default class FBVideoPlayer extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      player: null
    };
  }

  onReady = (id, player) => {
   this.setState({
     player: player,
   });
 }

  playVideo = () => {
    const { player } = this.state;
    if (player) player.play();
  };

  pauseVideo = () => {
    const { player } = this.state;
    if (player) player.pause();
  };

  render() {
    return (
      <div className="FBVideoPlayer">
        {this.props.appId ? (
          <div>
            <FacebookPlayer
              appId={`${this.props.appId ? this.props.appId : 'Default'}`}
              videoId={`${this.props.videoId ? this.props.videoId : 'Default'}`}
              id={`${this.props.id ? this.props.id : 'FBVideoPlayer'}`}
              className={this.props.className}
              allowfullscreen={this.props.allowfullscreen}
              autoplay={this.props.autoplay}
              width={this.props.width ? this.props.width : 600}
              showText={this.props.showText}
              showCaptions={this.props.showCaptions}
              onReady={ this.onReady }
              onStartedPlaying={this.props.onStartedPlaying}
              onPaused={this.props.onPaused}
              onFinishedPlaying={this.props.onFinishedPlaying}
              onStartedBuffering={this.props.onStartedBuffering}
              onFinishedBuffering={this.props.onStartedBuffering}
              onError={this.props.onError}
            />
            <button onClick={ this.playVideo }>Play</button>
             <button onClick={ this.pauseVideo }>Pause</button>
          </div>
        ) : (
          <div className="content">
            <div className="err-msg">
              <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/F_icon.svg/2000px-F_icon.svg.png" />
              <span>Facebook Video Player</span>
              <h3>Sorry, you need define (appId, videoId, and width)</h3>
            </div>
            <div className="code-snippet">
              <pre>
                <span>{'<FBVideoPlayer appId="yourAppId" videoId="yourVideoId" width={numberOfPixels}/>'}</span>
              </pre>
            </div>
          </div>
        )}
      </div>
    );
  }
}

```

# License

  ISC

---
_Source: https://npm.io/package/react-fb-player · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
