Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added host-option to embed youtube from 'nocookie'-domain #557

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ As of Chrome 66, [videos must be `muted` in order to play automatically](https:/
Prop | Description | Default
---- | ----------- | -------
`url` | The url of a video or song to play<br/>&nbsp; ◦ &nbsp;Can be an [array](#multiple-sources-and-tracks) or [`MediaStream`](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream) object
`host` | For YouTube, the host can be changed to embed from alternate sites. Can be set to `https://www.youtube-nocookie.com` or `https://www.youtube.com` | `https://www.youtube.com`
`playing` | Set to `true` or `false` to pause or play the media | `false`
`loop` | Set to `true` or `false` to loop the media | `false`
`controls` | Set to `true` or `false` to display native player controls<br />&nbsp; ◦ &nbsp;Vimeo, Twitch and Wistia player will always display controls | `false`
Expand Down
2 changes: 1 addition & 1 deletion dist/ReactPlayer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ReactPlayer.js.map

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion src/demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const MULTIPLE_SOURCES = [
class App extends Component {
state = {
url: null,
host: null,
pip: false,
playing: true,
volume: 0.8,
Expand Down Expand Up @@ -115,7 +116,7 @@ class App extends Component {
this.player = player
}
render () {
const { url, playing, volume, muted, loop, played, loaded, duration, playbackRate, pip } = this.state
const { url, host, playing, volume, muted, loop, played, loaded, duration, playbackRate, pip } = this.state
const SEPARATOR = ' · '

return (
Expand All @@ -129,6 +130,7 @@ class App extends Component {
width='100%'
height='100%'
url={url}
host={host}
pip={pip}
playing={playing}
loop={loop}
Expand Down Expand Up @@ -299,6 +301,13 @@ class App extends Component {
<button onClick={() => this.setState({ url: this.urlInput.value })}>Load</button>
</td>
</tr>
<tr>
<th>Host (Youtube Only)</th>
<td>
<input ref={input => { this.hostInput = input }} type='text' placeholder='Enter URL' />
<button onClick={() => this.setState({ host: this.hostInput.value })}>Load</button>
</td>
</tr>
</tbody></table>

<h2>State</h2>
Expand All @@ -310,6 +319,12 @@ class App extends Component {
{(url instanceof Array ? 'Multiple' : url) || 'null'}
</td>
</tr>
<tr>
<th>host</th>
<td className={!host ? 'faded' : ''}>
{(host instanceof Array ? 'Multiple' : host) || 'null'}
</td>
</tr>
<tr>
<th>playing</th>
<td>{playing ? 'true' : 'false'}</td>
Expand Down
1 change: 1 addition & 0 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class YouTube extends Component {
...parsePlaylist(url),
...playerVars
},
host: this.props.host,
events: {
onReady: this.props.onReady,
onStateChange: this.onStateChange,
Expand Down