Skip to content

Commit

Permalink
Merge pull request #59 from robertnealan/add-buffer-state
Browse files Browse the repository at this point in the history
Add Buffer Handler
  • Loading branch information
leoasis authored Apr 27, 2018
2 parents 8f0de39 + 9889574 commit d519b04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class MyComponentWithSound extends React.Component {
* *onResume (function)*: Function that gets called while the sound is resumed playing. It receives an object with properties `position` and `duration`.
* *onStop (function)*: Function that gets called while the sound playback is stopped. It receives an object with properties `position` and `duration`.
* *onFinishedPlaying (function)*: Function that gets called when the sound finishes playing (reached end of sound). It receives no parameters.
* *onBufferChange (function)*: Function that gets called when the sound buffering status changes. It receives a single boolean representing the buffer state.

## How to contribute

Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class Sound extends React.Component {
onResume: PropTypes.func,
onStop: PropTypes.func,
onFinishedPlaying: PropTypes.func,
onBufferChange: PropTypes.func,
autoLoad: PropTypes.bool,
loop: PropTypes.bool,
};
Expand All @@ -81,6 +82,7 @@ export default class Sound extends React.Component {
onResume: noop,
onStop: noop,
onFinishedPlaying: noop,
onBufferChange: noop,
autoLoad: false,
loop: false,
};
Expand Down Expand Up @@ -185,6 +187,9 @@ export default class Sound extends React.Component {
} else {
instance.props.onFinishedPlaying();
}
},
onbufferchange() {
instance.props.onBufferChange(this.isBuffering);
}
}, sound => {
this.sound = sound;
Expand Down

0 comments on commit d519b04

Please sign in to comment.