You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+113-100
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@
8
8
A React component to load a Brightcove Player in the browser.
9
9
10
10
## Brightcove Player Support
11
+
11
12
This library has [the same support characteristics as the Brightcove Player Loader](https://github.com/brightcove/player-loader#brightcove-player-support).
12
13
13
14
## Table of Contents
@@ -17,112 +18,136 @@ This library has [the same support characteristics as the Brightcove Player Load
17
18
18
19
19
20
-[Installation](#installation)
20
-
-[Usage](#usage)
21
-
-[JSX](#jsx)
22
-
-[Via `<script>` Tags](#via-script-tags)
23
-
-[CommonJS](#commonjs)
24
-
-[ES Module](#es-module)
21
+
-[Standard Usage with JSX](#standard-usage-with-jsx)
25
22
-[Props](#props)
26
23
-[`attrs`](#attrs)
27
24
-[`baseUrl`](#baseurl)
28
25
-[Other Props](#other-props)
26
+
-[Effects of Prop Changes](#effects-of-prop-changes)
var ReactPlayerLoader =window.BrightcoveReactPlayerLoader;
83
+
Provides attributes (props) to the component element.
91
84
92
-
var reactPlayerLoader =window.reactPlayerLoader=ReactDOM.render(
93
-
React.createElement(ReactPlayerLoader, {
94
-
accountId:'1234678',
95
-
onSuccess:function(success) {
96
-
// two ways to get the underlying player/iframe at this point.
97
-
console.log(success.ref)
98
-
console.log(reactPlayerLoader.player);
99
-
}
100
-
}),
101
-
document.getElementById('fixture')
102
-
);
85
+
For example, you may want to customize the `className` of the component (by default, `"brightcove-react-player-loader"`) by setting props on the component like so:
Used to override the base URL for the Brightcove Player being embedded.
96
+
97
+
Most users will never need this prop. By default, players are loaded from Brightcove's player CDN (`players.brightcove.net`).
98
+
99
+
### Other Props
100
+
101
+
All props not specified above are passed to the [Brightcove Player Loader](https://github.com/brightcove/player-loader#parameters) with a few differences:
102
+
103
+
1. We cannot expose the Player Loader promise easily, so you must use the `onSuccess` and `onFailure` callbacks.
104
+
2. If you don't provide an `onFailure` callback, the failure will be handled by throwing an error.
105
+
3. We need to use `refNode` and `refNodeInsert` internally, so those props will be ignored.
106
+
107
+
## Effects of Prop Changes
108
+
109
+
When a prop passed to this component changes, it will have one of two effects:
110
+
111
+
1. Dispose/reload the player. This is the most common case.
112
+
1. Update the player's state (e.g. fetch a new video).
113
+
114
+
The following props will update the player's state _without_ a reload:
108
115
109
-
1. Install the module (see [Installation](##Installation))
110
-
2.`require` the module in your javascript. IE `var ReactPlayerLoader = require('@brightcove/react-player-loader')`
111
-
3. Now you can use it however you like, with the `ReactPlayerLoader` variable.
112
-
4. See the example below for full usage.
116
+
-`catalogSearch`
117
+
-`catalogSequence`
118
+
-`playlistId`
119
+
-`playlistVideoId`
120
+
-`videoId`
113
121
114
-
> NOTE: React/ReactDOM/global are **NOT** required, they are only used to show a working example.
122
+
All other prop changes will cause a complete dispose/reload.
123
+
124
+
## View the Demo
125
+
126
+
This repository includes a barebones demo/example page.
127
+
128
+
1. Clone the repository
129
+
2. Move into the repository
130
+
3. Run `npm install`
131
+
4. Run `npm start`
132
+
5. Navigate to `http://localhost:9999` in a browser
133
+
134
+
## Alternate Usage
135
+
136
+
### ES Module (without JSX)
137
+
138
+
After installation, `import` the module in your JavaScript and use the `ReactPlayerLoader` component like any other component in your React application:
139
+
140
+
> **NOTE:**`React`/`ReactDOM` are **NOT** required, they are only used here to show a complete working example!
115
141
116
142
```js
117
-
var React =require('react');
118
-
var ReactDOM =require('react-dom');
119
-
vardocument=require('global/document');
120
-
var ReactPlayerLoader =require('@brightcove/react-player-loader');
// two ways to get the underlying player/iframe at this point.
127
152
console.log(success.ref)
128
153
console.log(reactPlayerLoader.player);
@@ -133,25 +158,21 @@ var reactPlayerLoader = ReactDOM.render(
133
158
134
159
```
135
160
136
-
### ES Module
161
+
### CommonJS
137
162
138
-
1. Install the module (see [Installation](##Installation))
139
-
2.`import` the module in your javascript. IE `import ReactPlayerLoader from '@brightcove/react-player-loader'`
140
-
3. Now you can use it however you like, with the `ReactPlayerLoader` variable.
141
-
4. See the example below for full usage.
163
+
After installation, `require` the module in your JavaScript and use the `ReactPlayerLoader` component like any other component in your React application:
142
164
143
-
> NOTE:React/ReactDOM/global are **NOT** required, they are only used to show a working example.
165
+
> **NOTE:**`React`/`ReactDOM` are **NOT** required, they are only used here to show a complete working example!
Provides attributes (props) to the component element.
190
+
After installation or loading from a CDN, use a `script` tag to include the module in your HTML and use the global `window.BrightcoveReactPlayerLoader` to construct the component.
171
191
172
-
For example, you may want to customize the `className` of the component (by default, `"brightcove-react-player-loader"`) by setting props on the component like so:
// two ways to get the underlying player/iframe at this point.
206
+
console.log(success.ref)
207
+
console.log(reactPlayerLoader.player);
208
+
}
209
+
}),
210
+
document.getElementById('fixture')
211
+
);
212
+
</script>
176
213
```
177
214
178
-
### `baseUrl`
179
-
Type: `string`
180
-
181
-
Used to override the base URL for the Brightcove Player being embedded.
182
-
183
-
Most users will never need this prop. By default, players are loaded from Brightcove's player CDN (`players.brightcove.net`).
184
-
185
-
### Other Props
186
-
All props not specified above are passed to the [Brightcove Player Loader](https://github.com/brightcove/player-loader#parameters) with a few differences:
187
-
188
-
1. We cannot expose the promise easily, so you will have to use the `onSuccess` and `onFailure` callbacks.
189
-
2. If you don't provide an `onFailure` callback, the failure will be handled by throwing an error.
190
-
3. We need to use `refNode` and `refNodeInsert` internally, so those options will not be used if passed in.
191
-
192
-
## View the Demo
193
-
This repository includes a barebones demo/example page.
194
-
195
-
1. Clone the repository
196
-
2. Move into the repository
197
-
3. Run `npm install`
198
-
4. Run `npm start`
199
-
5. Navigate to `http://localhost:9999` in a browser
0 commit comments