Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-facebook-player

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-facebook-player

React component for Facebook embedded videos API

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
145
decreased by-8.23%
Maintainers
1
Weekly downloads
 
Created
Source

react-youtube

Based on react-youtube, this component makes easier to integrate your React project with Facebook's Embedded Video Player API.

Installation

$ npm install react-facebook-player --save

Usage

const FacebookPlayer = require('react-facebook-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.
  /* ATTRIBUTES. Ref: http://bit.ly/29OOzWZ */
  allowfullscreen={ boolean }
  autoplay={ boolean }
  width={ number }
  showText={ boolean }
  showCaptions={ boolean }
  /* EVENTS. Ref: http://bit.ly/29JaA7J */
  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).

import React from 'react';
import ReactDOM from 'react-dom';
import FacebookPlayer from 'react-facebook-player';

class Example extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      player: null,
    };
  }

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

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

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

  render() {
    const { videoId, appId } = this.props;
    return (
      <div>
        <FacebookPlayer
          videoId={ videoId }
          appId={ appId }
          onReady={ this.onReady }
          />
        <button onClick={ this.playVideo }>Play</button>
        <button onClick={ this.pauseVideo }>Pause</button>
      </div>
    );
  }
}

ReactDOM.render(<Example />, document.getElementById('root'));

License

MIT

Keywords

FAQs

Package last updated on 23 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc