Skip to content

Commit

Permalink
Update standard code style
Browse files Browse the repository at this point in the history
Can't say I'm a huge fan, but consistency is key
  • Loading branch information
cookpete committed Feb 10, 2016
1 parent b8fbed2 commit 7231c45
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"rimraf": "^2.4.4",
"sass-loader": "^3.1.2",
"snazzy": "^2.0.1",
"standard": "^5.4.1",
"standard": "^6.0.4",
"style-loader": "^0.13.0",
"webpack": "^1.12.9",
"webpack-dev-middleware": "^1.4.0",
Expand Down
8 changes: 4 additions & 4 deletions src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class ReactPlayer extends Component {
static propTypes = propTypes;
static defaultProps = defaultProps;
static canPlay (url) {
return players.some(player => player.canPlay(url))
return players.some((player) => player.canPlay(url))
}
componentDidMount () {
this.progress()
Expand All @@ -25,7 +25,7 @@ export default class ReactPlayer extends Component {
this.props.volume !== nextProps.volume
)
}
seekTo = fraction => {
seekTo = (fraction) => {
const player = this.refs.player
if (player) {
player.seekTo(fraction)
Expand All @@ -48,7 +48,7 @@ export default class ReactPlayer extends Component {
}
this.progressTimeout = setTimeout(this.progress, PROGRESS_FREQUENCY)
};
renderPlayer = Player => {
renderPlayer = (Player) => {
const active = Player.canPlay(this.props.url)
const { youtubeConfig, soundcloudConfig, vimeoConfig, ...activeProps } = this.props
const props = active ? { ...activeProps, ref: 'player' } : {}
Expand All @@ -69,7 +69,7 @@ export default class ReactPlayer extends Component {
}
return (
<div style={style} className={this.props.className}>
{ players.map(this.renderPlayer) }
{players.map(this.renderPlayer)}
</div>
)
}
Expand Down
46 changes: 23 additions & 23 deletions src/demo/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class App extends Component {
loaded: 0,
duration: 0
};
load = url => {
load = (url) => {
this.setState({
url,
played: 0,
Expand All @@ -30,20 +30,20 @@ export default class App extends Component {
stop = () => {
this.setState({ url: null, playing: false })
};
setVolume = e => {
setVolume = (e) => {
this.setState({ volume: parseFloat(e.target.value) })
};
onSeekMouseDown = e => {
onSeekMouseDown = (e) => {
this.setState({ seeking: true })
};
onSeekChange = e => {
onSeekChange = (e) => {
this.setState({ played: parseFloat(e.target.value) })
};
onSeekMouseUp = e => {
onSeekMouseUp = (e) => {
this.setState({ seeking: false })
this.refs.player.seekTo(parseFloat(e.target.value))
};
onProgress = state => {
onProgress = (state) => {
// We only want to update time slider if we are not currently seeking
if (!this.state.seeking) {
this.setState(state)
Expand All @@ -62,7 +62,7 @@ export default class App extends Component {
renderLoadButton = (url, label) => {
return (
<button onClick={() => this.load(url)}>
{ label }
{label}
</button>
)
};
Expand Down Expand Up @@ -94,9 +94,9 @@ export default class App extends Component {
onPause={() => this.setState({ playing: false })}
onBuffer={() => console.log('onBuffer')}
onEnded={() => this.setState({ playing: false })}
onError={e => console.log('onError', e)}
onError={(e) => console.log('onError', e)}
onProgress={this.onProgress}
onDuration={duration => this.setState({ duration })}
onDuration={(duration) => this.setState({ duration })}
/>

<table><tbody>
Expand Down Expand Up @@ -140,30 +140,30 @@ export default class App extends Component {
<tr>
<th>YouTube</th>
<td>
{ this.renderLoadButton('https://www.youtube.com/watch?v=oUFJJNQGwhk', 'Test A') }
{ this.renderLoadButton('https://www.youtube.com/watch?v=jNgP6d9HraI', 'Test B') }
{this.renderLoadButton('https://www.youtube.com/watch?v=oUFJJNQGwhk', 'Test A')}
{this.renderLoadButton('https://www.youtube.com/watch?v=jNgP6d9HraI', 'Test B')}
</td>
</tr>
<tr>
<th>SoundCloud</th>
<td>
{ this.renderLoadButton('https://soundcloud.com/miami-nights-1984/accelerated', 'Test A') }
{ this.renderLoadButton('https://soundcloud.com/bonobo/flashlight', 'Test B') }
{this.renderLoadButton('https://soundcloud.com/miami-nights-1984/accelerated', 'Test A')}
{this.renderLoadButton('https://soundcloud.com/bonobo/flashlight', 'Test B')}
</td>
</tr>
<tr>
<th>Vimeo</th>
<td>
{ this.renderLoadButton('https://vimeo.com/90509568', 'Test A') }
{ this.renderLoadButton('https://vimeo.com/94502406', 'Test B') }
{this.renderLoadButton('https://vimeo.com/90509568', 'Test A')}
{this.renderLoadButton('https://vimeo.com/94502406', 'Test B')}
</td>
</tr>
<tr>
<th>Files</th>
<td>
{ this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4', 'MP4') }
{ this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv', 'OGV') }
{ this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm', 'WEBM') }
{this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4', 'MP4')}
{this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv', 'OGV')}
{this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm', 'WEBM')}
</td>
</tr>
<tr>
Expand All @@ -187,23 +187,23 @@ export default class App extends Component {
<table><tbody>
<tr>
<th>url</th>
<td className={ !url ? 'faded' : '' }>{ url || 'null' }</td>
<td className={!url ? 'faded' : ''}>{url || 'null'}</td>
</tr>
<tr>
<th>playing</th>
<td>{ playing ? 'true' : 'false' }</td>
<td>{playing ? 'true' : 'false'}</td>
</tr>
<tr>
<th>volume</th>
<td>{ volume.toFixed(3) }</td>
<td>{volume.toFixed(3)}</td>
</tr>
<tr>
<th>played</th>
<td>{ played.toFixed(3) }</td>
<td>{played.toFixed(3)}</td>
</tr>
<tr>
<th>loaded</th>
<td>{ loaded.toFixed(3) }</td>
<td>{loaded.toFixed(3)}</td>
</tr>
<tr>
<th>duration</th>
Expand Down
2 changes: 1 addition & 1 deletion src/demo/Duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
export default function Duration ({ className, seconds }) {
return (
<time dateTime={`P${Math.round(seconds)}S`} className={className}>
{ format(seconds) }
{format(seconds)}
</time>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/players/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class Base extends Component {
// When seeking before player is ready, store value and seek later
if (!this.isReady && fraction !== 0) {
this.seekOnReady = fraction
setTimeout(() => this.seekOnReady = null, SEEK_ON_READY_EXPIRY)
setTimeout(() => { this.seekOnReady = null }, SEEK_ON_READY_EXPIRY)
}
}
onPlay = () => {
Expand Down
12 changes: 6 additions & 6 deletions src/players/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class SoundCloud extends Base {
return Promise.resolve(window[SDK_GLOBAL])
}
return new Promise((resolve, reject) => {
loadScript(SDK_URL, err => {
loadScript(SDK_URL, (err) => {
if (err) {
reject(err)
} else {
Expand All @@ -44,7 +44,7 @@ export default class SoundCloud extends Base {
return Promise.resolve(songData[url])
}
return fetch(RESOLVE_URL + '?url=' + url + '&client_id=' + this.props.soundcloudConfig.clientId)
.then(response => {
.then((response) => {
if (response.status >= 200 && response.status < 300) {
songData[url] = response.json()
return songData[url]
Expand All @@ -57,8 +57,8 @@ export default class SoundCloud extends Base {
}
load (url) {
this.stop()
this.getSDK().then(SC => {
this.getSongData(url).then(data => {
this.getSDK().then((SC) => {
this.getSongData(url).then((data) => {
if (url !== this.props.url) {
return // Abort if url changes during async requests
}
Expand All @@ -70,15 +70,15 @@ export default class SoundCloud extends Base {
if (image) {
this.setState({ image: image.replace('-large', '-t500x500') })
}
SC.stream(data.uri, player => {
SC.stream(data.uri, (player) => {
this.player = player
player._player.on('stateChange', this.onStateChange)
this.onReady()
})
}, this.props.onError)
}, this.props.onError)
}
onStateChange = state => {
onStateChange = (state) => {
if (state === 'playing') this.onPlay()
if (state === 'paused') this.props.onPause()
if (state === 'loading') this.props.onBuffer()
Expand Down
2 changes: 1 addition & 1 deletion src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class Vimeo extends Base {
getFractionLoaded () {
return this.fractionLoaded || null
}
onMessage = e => {
onMessage = (e) => {
if (!MATCH_MESSAGE_ORIGIN.test(e.origin)) return
this.origin = this.origin || e.origin
const data = JSON.parse(e.data)
Expand Down
6 changes: 3 additions & 3 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class YouTube extends Base {
if (previousOnReady) previousOnReady()
resolve(window[SDK_GLOBAL])
}
loadScript(SDK_URL, err => {
loadScript(SDK_URL, (err) => {
if (err) reject(err)
})
})
Expand All @@ -63,7 +63,7 @@ export default class YouTube extends Base {
return
}
this.loadingSDK = true
this.getSDK().then(YT => {
this.getSDK().then((YT) => {
this.player = new YT.Player(this.playerId, {
width: '100%',
height: '100%',
Expand All @@ -80,7 +80,7 @@ export default class YouTube extends Base {
this.onReady()
},
onStateChange: this.onStateChange,
onError: event => this.props.onError(event.data)
onError: (event) => this.props.onError(event.data)
}
})
}, this.props.onError)
Expand Down
36 changes: 18 additions & 18 deletions test/karma/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('ReactPlayer', () => {
}

const testDuration = (url, done) => {
const onDuration = duration => {
const onDuration = (duration) => {
if (duration && duration > 0) done()
}
render(<ReactPlayer url={url} playing onDuration={onDuration} />, div)
Expand All @@ -52,37 +52,37 @@ describe('ReactPlayer', () => {
}

describe('YouTube', () => {
it('fires onPlay', done => testPlay(TEST_YOUTUBE_URL, done))
it('fires onPause', done => testPause(TEST_YOUTUBE_URL, done))
it('fires onDuration', done => testDuration(TEST_YOUTUBE_URL, done))
it('fires onError', done => testError(TEST_YOUTUBE_ERROR, done))
it('fires onPlay', (done) => testPlay(TEST_YOUTUBE_URL, done))
it('fires onPause', (done) => testPause(TEST_YOUTUBE_URL, done))
it('fires onDuration', (done) => testDuration(TEST_YOUTUBE_URL, done))
it('fires onError', (done) => testError(TEST_YOUTUBE_ERROR, done))

it('starts at a specified time', done => {
const onProgress = state => {
it('starts at a specified time', (done) => {
const onProgress = (state) => {
if (state.played > 0.9) done()
}
render(<ReactPlayer url={TEST_YOUTUBE_URL + '?start=22m10s'} playing onProgress={onProgress} />, div)
})
})

describe('SoundCloud', () => {
it('fires onPlay', done => testPlay(TEST_SOUNDCLOUD_URL, done))
it('fires onPause', done => testPause(TEST_SOUNDCLOUD_URL, done))
it('fires onDuration', done => testDuration(TEST_SOUNDCLOUD_URL, done))
it('fires onError', done => testError(TEST_SOUNDCLOUD_ERROR, done))
it('fires onPlay', (done) => testPlay(TEST_SOUNDCLOUD_URL, done))
it('fires onPause', (done) => testPause(TEST_SOUNDCLOUD_URL, done))
it('fires onDuration', (done) => testDuration(TEST_SOUNDCLOUD_URL, done))
it('fires onError', (done) => testError(TEST_SOUNDCLOUD_ERROR, done))
})

describe('Vimeo', () => {
it('fires onPlay a Vimeo video', done => testPlay(TEST_VIMEO_URL, done))
it('fires onPause a Vimeo video', done => testPause(TEST_VIMEO_URL, done))
it('fires onDuration for Vimeo video', done => testDuration(TEST_VIMEO_URL, done))
it('fires onPlay a Vimeo video', (done) => testPlay(TEST_VIMEO_URL, done))
it('fires onPause a Vimeo video', (done) => testPause(TEST_VIMEO_URL, done))
it('fires onDuration for Vimeo video', (done) => testDuration(TEST_VIMEO_URL, done))
})

describe('FilePlayer', () => {
it('fires onPlay a file', done => testPlay(TEST_FILE_URL, done))
it('fires onPause a file', done => testPause(TEST_FILE_URL, done))
it('fires onDuration for file', done => testDuration(TEST_FILE_URL, done))
it('fires onError for file', done => testError(TEST_FILE_ERROR, done))
it('fires onPlay a file', (done) => testPlay(TEST_FILE_URL, done))
it('fires onPause a file', (done) => testPause(TEST_FILE_URL, done))
it('fires onDuration for file', (done) => testDuration(TEST_FILE_URL, done))
it('fires onError for file', (done) => testError(TEST_FILE_ERROR, done))
})

it('switches between media', function (done) {
Expand Down

0 comments on commit 7231c45

Please sign in to comment.