From 355ffc54c88b3a64a337d37e3844613658541193 Mon Sep 17 00:00:00 2001 From: Pete Cook Date: Mon, 14 Dec 2015 17:08:48 +0000 Subject: [PATCH 1/6] Set Vimeo iframe src in play method instead of render * Allows us to render the Vimeo player without a valid URL, which helps us fix bugs * More or less reverts commit d308aa62c70d902f95c1184d704f54ee1fcc98d3 --- src/players/Vimeo.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/players/Vimeo.js b/src/players/Vimeo.js index 219ef08f..6d4480f8 100644 --- a/src/players/Vimeo.js +++ b/src/players/Vimeo.js @@ -1,5 +1,5 @@ import React from 'react' -import queryString from 'query-string' +import { stringify } from 'query-string' import propTypes from '../propTypes' import Base from './Base' @@ -29,11 +29,18 @@ export default class Vimeo extends Base { this.iframe = this.refs.iframe super.componentDidMount() } - shouldComponentUpdate (nextProps) { - return this.props.url !== nextProps.url + shouldComponentUpdate () { + return false } play (url) { - if (!url) { + if (url) { + const id = url.match(MATCH_URL)[3] + const iframeParams = { + ...DEFAULT_IFRAME_PARAMS, + ...this.props.vimeoConfig.iframeParams + } + this.iframe.src = IFRAME_SRC + id + '?' + stringify(iframeParams) + } else { this.postMessage('play') } } @@ -41,7 +48,7 @@ export default class Vimeo extends Base { this.postMessage('pause') } stop () { - // No need + this.iframe.src = '' } seekTo (fraction) { this.postMessage('seekTo', this.duration * fraction) @@ -81,19 +88,10 @@ export default class Vimeo extends Base { return this.iframe.contentWindow && this.iframe.contentWindow.postMessage(data, this.origin) } render () { - const id = this.props.url.match(MATCH_URL)[3] const style = { width: '100%', height: '100%' } - const iframeParams = { ...DEFAULT_IFRAME_PARAMS, ...this.props.vimeoConfig.iframeParams } - return ( -