import React, { Component } from 'react'

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

const SUPPORTED_PROPS = Object.keys(propTypes)

export default function createSinglePlayer (activePlayer) {
  return class SinglePlayer extends Component {
    static displayName = `${activePlayer.displayName}Player`
    static propTypes = propTypes
    static defaultProps = defaultProps
    static canPlay = activePlayer.canPlay

    shouldComponentUpdate (nextProps) {
      return !isEqual(this.props, nextProps)
    }
    componentWillUpdate (nextProps) {
      this.config = getConfig(nextProps, defaultProps)
    }
    getDuration = () => {
      if (!this.player) return null
      return this.player.getDuration()
    }
    getCurrentTime = () => {
      if (!this.player) return null
      return this.player.getCurrentTime()
    }
    getSecondsLoaded = () => {
      if (!this.player) return null
      return this.player.getSecondsLoaded()
    }
    getInternalPlayer = (key = 'player') => {
      if (!this.player) return null
      return this.player.getInternalPlayer(key)
    }
    seekTo = fraction => {
      if (!this.player) return null
      this.player.seekTo(fraction)
    }
    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 (
        <Wrapper style={{ ...style, width, height }} {...otherProps}>
          <Player
            {...this.props}
            ref={this.ref}
            activePlayer={activePlayer}
            config={getConfig(this.props, defaultProps)}
          />
        </Wrapper>
      )
    }
  }
}

@@ -524,16 +524,71 @@
 anPlay%0A%0A
+    config = getConfig(this.props, defaultProps, true)%0A
     shou
@@ -1870,43 +1870,19 @@
 ig=%7B
-getConfig(this.props, defaultProps)
+this.config
 %7D%0A  

Fix simple player config logic