Skip to content

Commit

Permalink
Call play() when initializing instead of using howler autoplay
Browse files Browse the repository at this point in the history
Fixes #22
  • Loading branch information
Stenerson committed Nov 26, 2016
1 parent ea935e5 commit 1f9d7e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ open http://localhost:3000
Prop | Default | Description
---- | ------- | -----------
src | | The src of songs for playing. Can be a string or an array
playing | true | Set to `true` or `false` to pause or play the media. This also invokes autoplay on initial load
playing | true | Set to `true` or `false` to pause or play the media.<br>Setting to `true` on initial load will play the audio immediately after it is loaded
loop | false | Set to `true` or `false` to enable/disable loop
mute | false | Set to `true` or `false` to mute/unmute current audio
volume | 1.0 | The volume of the specific howl, from `0.0` to `1.0`
Expand Down
5 changes: 4 additions & 1 deletion src/ReactHowler.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ReactHowler extends Component {
if (typeof Howl !== 'undefined') { // Check if window is available
this.howler = new Howl({
src: props.src,
autoplay: props.playing,
mute: props.mute,
loop: props.loop,
volume: props.volume,
Expand All @@ -43,6 +42,10 @@ class ReactHowler extends Component {
onload: props.onLoad,
onloaderror: props.onLoadError
})

if (props.playing) {
this.play();
}
}
}

Expand Down

0 comments on commit 1f9d7e7

Please sign in to comment.