Skip to content

Commit

Permalink
Remove need for Vimeo player IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Apr 30, 2017
1 parent e4dc22a commit 214a7af
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Base from './Base'

const SDK_URL = 'https://player.vimeo.com/api/player.js'
const SDK_GLOBAL = 'Vimeo'
const PLAYER_ID = 'vimeo-player'
const MATCH_URL = /https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/
const BLANK_VIDEO_URL = 'https://vimeo.com/127250231'

Expand All @@ -18,14 +17,11 @@ const DEFAULT_OPTIONS = {
title: false
}

let playerIdCount = 0

export default class Vimeo extends Base {
static displayName = 'Vimeo'
static canPlay (url) {
return MATCH_URL.test(url)
}
playerId = PLAYER_ID + '-' + playerIdCount++
componentDidMount () {
const { url, vimeoConfig } = this.props
if (!url && vimeoConfig.preload) {
Expand Down Expand Up @@ -58,7 +54,7 @@ export default class Vimeo extends Base {
}
this.loadingSDK = true
this.getSDK().then(Vimeo => {
this.player = new Vimeo.Player(this.playerId, {
this.player = new Vimeo.Player(this.container, {
...DEFAULT_OPTIONS,
...this.props.vimeoConfig.playerOptions,
id,
Expand Down Expand Up @@ -117,14 +113,14 @@ export default class Vimeo extends Base {
getFractionLoaded () {
return this.fractionLoaded || null
}
ref = iframe => {
this.iframe = iframe
ref = container => {
this.container = container
}
render () {
const style = {
height: '100%',
display: this.props.url ? 'block' : 'none'
}
return <div style={style} id={this.playerId} />
return <div style={style} ref={this.ref} />
}
}

0 comments on commit 214a7af

Please sign in to comment.