Skip to content

Commit

Permalink
Change progressFrequency to progressInterval
Browse files Browse the repository at this point in the history
progressFrequency still works, but will log a warning to the console
Closes #317
  • Loading branch information
cookpete committed Feb 7, 2018
1 parent 22dd274 commit 663bd08
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Prop | Description | Default
`width` | Sets the width of the player | `640px`
`height` | Sets the height of the player | `360px`
`style` | Add [inline styles](https://facebook.github.io/react/tips/inline-styles.html) to the root element | `{}`
`progressFrequency` | The time between `onProgress` callbacks, in milliseconds | `1000`
`progressInterval` | The time between `onProgress` callbacks, in milliseconds | `1000`
`playsinline` | Applies the `playsinline` attribute where supported | `false`
`config` | Override options for the various players, see [config prop](#config-prop)

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export interface ReactPlayerProps {
width?: string | number;
height?: string | number;
style?: Object;
progressFrequency?: number;
progressInterval?: number;
playsinline?: boolean;
config?: Config;
soundcloudConfig?: SoundCloudConfig;
Expand Down
6 changes: 5 additions & 1 deletion src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export default class ReactPlayer extends Component {
config = getConfig(this.props, defaultProps, true)
componentDidMount () {
this.progress()
if (this.props.progressFrequency) {
const message = 'ReactPlayer: %cprogressFrequency%c is deprecated, please use %cprogressInterval%c instead'
console.warn(message, 'font-weight: bold', '', 'font-weight: bold', '')
}
}
componentWillUnmount () {
clearTimeout(this.progressTimeout)
Expand Down Expand Up @@ -69,7 +73,7 @@ export default class ReactPlayer extends Component {
this.prevLoaded = progress.loaded
}
}
this.progressTimeout = setTimeout(this.progress, this.props.progressFrequency)
this.progressTimeout = setTimeout(this.progress, this.props.progressFrequency || this.props.progressInterval)
}
getActivePlayer (url) {
for (let Player of players) {
Expand Down
4 changes: 2 additions & 2 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const propTypes = {
width: oneOfType([ string, number ]),
height: oneOfType([ string, number ]),
style: object,
progressFrequency: number,
progressInterval: number,
playsinline: bool,
config: shape({
soundcloud: shape({
Expand Down Expand Up @@ -67,7 +67,7 @@ export const defaultProps = {
width: '640px',
height: '360px',
style: {},
progressFrequency: 1000,
progressInterval: 1000,
playsinline: false,
config: {
soundcloud: {
Expand Down

0 comments on commit 663bd08

Please sign in to comment.