From 4c11f58014f293011f80481bc94e1313d218b336 Mon Sep 17 00:00:00 2001 From: wajerrr Date: Thu, 13 Jul 2017 14:53:47 +0100 Subject: [PATCH 1/3] added autoplay prop --- README.md | 3 +++ src/addons/SoundPlayerContainer.js | 1 + src/addons/withSoundCloudAudio.js | 7 +++++++ styles/buttons.css | 1 - styles/cover.css | 5 ++--- styles/progress.css | 1 - styles/volume.css | 1 - 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 77b2e7e..19f6247 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,9 @@ _(String)_ - this could be regular link from SoundCloud web app which points to // playlist "https://soundcloud.com/stepan-i-meduza-official/sets/dolgo-obyasnyat-ep" ``` +##### `autoplay` + +_(boolean)_ - if set to `true` using `streamUrl` will autoplay track when buffered. ##### `onReady` diff --git a/src/addons/SoundPlayerContainer.js b/src/addons/SoundPlayerContainer.js index 81d0c52..44dc01b 100644 --- a/src/addons/SoundPlayerContainer.js +++ b/src/addons/SoundPlayerContainer.js @@ -35,6 +35,7 @@ SoundPlayerContainer.propTypes = { onStopTrack: PropTypes.func, onPauseTrack: PropTypes.func, onVolumeChange: PropTypes.func, + autoPlay: PropTypes.bool, onReady: PropTypes.func }; diff --git a/src/addons/withSoundCloudAudio.js b/src/addons/withSoundCloudAudio.js index 5312a0e..cbaff2d 100644 --- a/src/addons/withSoundCloudAudio.js +++ b/src/addons/withSoundCloudAudio.js @@ -81,6 +81,13 @@ export default function withSoundCloudAudio (WrappedComponent) { soundCloudAudio.on('pause', ::this.onAudioPaused); soundCloudAudio.on('ended', ::this.onAudioEnded); soundCloudAudio.on('volumechange', ::this.onVolumeChange); + if (this.props.autoPlay) { + soundCloudAudio.on('canplay', ::this.autoplay); + } + } + + autoplay() { + this.soundCloudAudio.play(); } onSeekingTrack() { diff --git a/styles/buttons.css b/styles/buttons.css index 2f06bd0..2842ef7 100644 --- a/styles/buttons.css +++ b/styles/buttons.css @@ -13,7 +13,6 @@ border: 0; outline: none; cursor: pointer; - -webkit-transition: box-shadow, .05s ease, -webkit-transform; transition: box-shadow, .05s ease, -webkit-transform; transition: transform, box-shadow, .05s ease; transition: transform, box-shadow, .05s ease, -webkit-transform; diff --git a/styles/cover.css b/styles/cover.css index 10f9405..d76fd11 100644 --- a/styles/cover.css +++ b/styles/cover.css @@ -14,8 +14,7 @@ } .sb-soundplayer-cover:after { content: ''; - background: -webkit-linear-gradient(rgba(0,0,0,.05), rgba(0,0,0,.35)); - background: linear-gradient(rgba(0,0,0,.05), rgba(0,0,0,.35)); + background: linear-gradient(rgba(0, 0, 0, .05), rgba(0, 0, 0, .35)); position: absolute; z-index: 1; width: 100%; @@ -40,7 +39,7 @@ font-size: 18px; } .sb-soundplayer-cover-logo { - color: rgba(255,255,255,.9); + color: rgba(255, 255, 255, .9); width: 100px; height: 14px; position: absolute; diff --git a/styles/progress.css b/styles/progress.css index 523576c..45a37df 100644 --- a/styles/progress.css +++ b/styles/progress.css @@ -9,6 +9,5 @@ .sb-soundplayer-progress-inner { background-color: #FC561E; height: 100%; - -webkit-transition: width .2s ease-in; transition: width .2s ease-in; } diff --git a/styles/volume.css b/styles/volume.css index 782221f..5f61a54 100644 --- a/styles/volume.css +++ b/styles/volume.css @@ -9,7 +9,6 @@ .sb-soundplayer-volume div { overflow: hidden; width:0; - -webkit-transition: width .2s ease-out; transition: width .2s ease-out; position: relative; } From c3357c2b4aea0b2a00adce4a1c40433e5c83a31f Mon Sep 17 00:00:00 2001 From: wajer Date: Thu, 13 Jul 2017 15:26:01 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19f6247..7a6ee06 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ _(String)_ - this could be regular link from SoundCloud web app which points to // playlist "https://soundcloud.com/stepan-i-meduza-official/sets/dolgo-obyasnyat-ep" ``` -##### `autoplay` +##### `autoPlay` _(boolean)_ - if set to `true` using `streamUrl` will autoplay track when buffered. From a303f2c8411359e47dc55fd1f28dbe957f7c2231 Mon Sep 17 00:00:00 2001 From: wajer Date: Thu, 13 Jul 2017 15:28:08 +0100 Subject: [PATCH 3/3] Update withSoundCloudAudio.js --- src/addons/withSoundCloudAudio.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/addons/withSoundCloudAudio.js b/src/addons/withSoundCloudAudio.js index cbaff2d..4301b09 100644 --- a/src/addons/withSoundCloudAudio.js +++ b/src/addons/withSoundCloudAudio.js @@ -82,11 +82,11 @@ export default function withSoundCloudAudio (WrappedComponent) { soundCloudAudio.on('ended', ::this.onAudioEnded); soundCloudAudio.on('volumechange', ::this.onVolumeChange); if (this.props.autoPlay) { - soundCloudAudio.on('canplay', ::this.autoplay); + soundCloudAudio.on('canplay', ::this.autoPlay); } } - autoplay() { + autoPlay() { this.soundCloudAudio.play(); }