From 9907be21d4913dbd08398f5d9513d141712b7c64 Mon Sep 17 00:00:00 2001 From: Rob Nealan Date: Wed, 14 Mar 2018 18:11:55 -0700 Subject: [PATCH 1/2] Adds a prop method handler for changing buffer state based on SM2s own internal onbufferchange method. Also adds info to README --- README.md | 2 +- src/index.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d81f4d0..031896e 100644 --- a/README.md +++ b/README.md @@ -71,7 +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 Feel free to fork and send PRs or issues, be it for features, bug fixes, or documentation! diff --git a/src/index.js b/src/index.js index 8c61079..dd8e302 100755 --- a/src/index.js +++ b/src/index.js @@ -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, }; @@ -81,6 +82,7 @@ export default class Sound extends React.Component { onResume: noop, onStop: noop, onFinishedPlaying: noop, + onBufferChange: noop, autoLoad: false, loop: false, }; @@ -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; From 98895743ee5527bce885fb96a12afa717361ba2e Mon Sep 17 00:00:00 2001 From: Rob Nealan Date: Wed, 14 Mar 2018 18:13:45 -0700 Subject: [PATCH 2/2] Adds missing new line in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 031896e..fa46470 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ class MyComponentWithSound extends React.Component { * *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 Feel free to fork and send PRs or issues, be it for features, bug fixes, or documentation!