Giter Site home page Giter Site logo

react-player-loader's Introduction

@brightcove/react-player-loader

Build Status Greenkeeper badge

NPM

A React component to load a Brightcove Player in the browser.

Brightcove Player Support

Currently, this library supports Brightcove Players v6.11.0 and higher.

Table of Contents

Installation

npm install --save @brightcove/react-player-loader

Usage

To include @brightcove/react-player-loader on your website or web application, use any of the following methods.

JSX

  1. Install the module (see Installation)
  2. import the module in your javascript. IE import ReactPlayerLoader from '@brightcove/react-player-loader'
  3. Now you can use it however you like, with the ReactPlayerLoader variable.
  4. See the example below for full usage.

NOTE: React/ReactDOM/global are NOT required, they are only used to show a working example.

import document from 'global/document';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactPlayerLoader from '@brightcove/react-player-loader';

let reactPlayerLoader;
const onSuccess = function(success) {
  // two ways to get the underlying player/iframe at this point.
  console.log(success.ref)
  console.log(reactPlayerLoader.player);
};

reactPlayerLoader = ReactDOM.render(
  <ReactPlayerLoader accountId='1234678' onSuccess={onSuccess}/>,
  document.getElementById('fixture')
);

Via <script> Tags

  1. Get the script however you prefer
  2. Include the script in your html
  3. Use the BrightcoveReactPlayerLoader object that this module exports on the window object.
  4. See the example below for full usage.

NOTE: React/ReactDOM are NOT required, they are only used to show a working example.

<div id='fixture'></div>
<script src="//path/to/react.min.js"></script>
<script src="//path/to/react-dom.min.js"></script>
<script src="//path/to/brightcove-react-player-loader.min.js"></script>
<script>

  var React = window.React;
  var ReactDOM = window.ReactDOM;
  var ReactPlayerLoader = window.BrightcoveReactPlayerLoader;

  var reactPlayerLoader = window.reactPlayerLoader = ReactDOM.render(
    React.createElement(ReactPlayerLoader, {
      accountId: '1234678',
      onSuccess: function(success) {
        // two ways to get the underlying player/iframe at this point.
        console.log(success.ref)
        console.log(reactPlayerLoader.player);
      }
    }),
    document.getElementById('fixture')
  );

</script>

CommonJS

  1. Install the module (see Installation)
  2. require the module in your javascript. IE var ReactPlayerLoader = require('@brightcove/react-player-loader')
  3. Now you can use it however you like, with the ReactPlayerLoader variable.
  4. See the example below for full usage.

NOTE: React/ReactDOM/global are NOT required, they are only used to show a working example.

var React = require('react');
var ReactDOM = require('react-dom');
var document = require('global/document');
var ReactPlayerLoader = require('@brightcove/react-player-loader');

var reactPlayerLoader = ReactDOM.render(
  React.createElement(ReactPlayerLoader, {
    accountId: '1234678',
    onSuccess: function(success) {
      // two ways to get the underlying player/iframe at this point.
      console.log(success.ref)
      console.log(reactPlayerLoader.player);
    }
  }),
  document.getElementById('fixture')
);

ES Module

  1. Install the module (see Installation)
  2. import the module in your javascript. IE import ReactPlayerLoader from '@brightcove/react-player-loader'
  3. Now you can use it however you like, with the ReactPlayerLoader variable.
  4. See the example below for full usage.

NOTE: React/ReactDOM/global are NOT required, they are only used to show a working example.

import document from 'global/document';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactPlayerLoader  from '@brightcove/react-player-loader';

const reactPlayerLoader = ReactDOM.render(
  React.createElement(ReactPlayerLoader, {
    accountId: '1234678',
    onSuccess(success) {
      // two ways to get the underlying player/iframe at this point.
      console.log(success.ref)
      console.log(reactPlayerLoader.player);
    }
  }),
  document.getElementById('fixture')
);

Options

See the Player Loader page for most options. There are four differences

  1. We cannot export the promise easily, so you will have to use the onSuccess and onFailure callbacks
  2. If you don't provide an onFailure callback the failure will be handle by throwing an error
  3. We need to use refNode and refNodeInsert internally, so those options will not be used if passed in.
  4. We allow a baseUrl string option, so that the baseUrl can be changed. Player loader makes you use setBaseUrl() which you won't have access to.

View the Demo

  1. clone the repo
  2. move into the repo
  3. run npm i
  4. run npm run start
  5. Navigate to http://localhost:9999 in the browser

react-player-loader's People

Contributors

misteroneill avatar brandonocasey avatar greenkeeper[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.