diff --git a/README.md b/README.md index 17bb68c..4995963 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Prop | Description `onReady` | Called when media is loaded and ready to play. If `playing` is set to `true`, media will play immediately `onStart` | Called when media starts playing `onPlay` | Called when media starts or resumes playing after pausing or buffering -`onProgress` | Callback containing `played` and `loaded` progress as a fraction
eg `{ played: 0.12, loaded: 0.34 }` +`onProgress` | Callback containing progress `played`, `loaded` (fraction), `playedSeconds` and `loadedSeconds` (seconds)
eg `{ played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 }` `onDuration` | Callback containing duration of the media, in seconds `onPause` | Called when media is paused `onBuffer` | Called when media starts buffering diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index 1aa80a1..c23247c 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -39,12 +39,19 @@ export default class ReactPlayer extends Component { if (this.props.url && this.player) { const loaded = this.player.getFractionLoaded() || 0 const played = this.player.getFractionPlayed() || 0 + const duration = this.player.getDuration() const progress = {} if (loaded !== this.prevLoaded) { progress.loaded = loaded + if (duration) { + progress.loadedSeconds = progress.loaded * duration + } } if (played !== this.prevPlayed) { progress.played = played + if (duration) { + progress.playedSeconds = progress.played * duration + } } if (progress.loaded || progress.played) { this.props.onProgress(progress)