Skip to content

Commit

Permalink
set player volume on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Fauntleroy committed Oct 23, 2015
1 parent f1395d1 commit d984daf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/players/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ export default class Base extends Component {
}
this.updateTimeout = setTimeout(this.update, UPDATE_FREQUENCY)
}
onReady = () => {
this.setVolume(this.props.volume)
}
}
1 change: 1 addition & 0 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class FilePlayer extends Base {
this.player.onplay = this.props.onPlay
this.player.onpause = this.props.onPause
super.componentDidMount()
this.onReady();
}
shouldComponentUpdate (nextProps) {
return this.props.url !== nextProps
Expand Down
1 change: 1 addition & 0 deletions src/players/SoundCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class SoundCloud extends Base {
}
SC.stream(data.uri, this.options, player => {
this.player = player
this.onReady()
player.play()
player._player.on('stateChange', this.onStateChange)
})
Expand Down
1 change: 1 addition & 0 deletions src/players/Vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class Vimeo extends Base {
this.postMessage('addEventListener', 'pause')
this.postMessage('addEventListener', 'finish')
}
if (data.event === 'ready') this.onReady()
if (data.event === 'playProgress') this.fractionPlayed = data.data.percent
if (data.event === 'loadProgress') this.fractionLoaded = data.data.percent
if (data.event === 'play') this.props.onPlay()
Expand Down
1 change: 1 addition & 0 deletions src/players/YouTube.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class YouTube extends Base {
videoId: id,
playerVars: { ...DEFAULT_PLAYER_VARS, ...this.props.youtubeConfig.playerVars },
events: {
onReady: this.onReady,
onStateChange: this.onStateChange,
onError: this.props.onError
}
Expand Down

0 comments on commit d984daf

Please sign in to comment.