Skip to content

Commit

Permalink
Add single player wrapper div
Browse files Browse the repository at this point in the history
Keeps structure consistent with the full player, and enable props like `className` and `wrapper`
Fixes cookpete/react-player#346
  • Loading branch information
Webmaster1116 committed Mar 15, 2018
1 parent 6ce908e commit 8c63467
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/singlePlayer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { Component } from 'react'

import { propTypes, defaultProps } from './props'
import { propTypes, defaultProps, DEPRECATED_CONFIG_PROPS } from './props'
import { getConfig, omit, isEqual } from './utils'
import Player from './Player'
import { isEqual, getConfig } from './utils'

const SUPPORTED_PROPS = Object.keys(propTypes)

export default function createSinglePlayer (activePlayer) {
return class SinglePlayer extends Component {
Expand All @@ -17,16 +19,24 @@ export default function createSinglePlayer (activePlayer) {
componentWillUpdate (nextProps) {
this.config = getConfig(nextProps, defaultProps)
}
ref = player => {
this.player = player
}
render () {
if (!activePlayer.canPlay(this.props.url)) {
return null
}
const { style, width, height, wrapper: Wrapper } = this.props
const otherProps = omit(this.props, SUPPORTED_PROPS, DEPRECATED_CONFIG_PROPS)
return (
<Player
{...this.props}
activePlayer={activePlayer}
config={getConfig(this.props, defaultProps)}
/>
<Wrapper style={{ ...style, width, height }} {...otherProps}>
<Player
{...this.props}
ref={this.ref}
activePlayer={activePlayer}
config={getConfig(this.props, defaultProps)}
/>
</Wrapper>
)
}
}
Expand Down

0 comments on commit 8c63467

Please sign in to comment.