Skip to content

Commit

Permalink
Do not always call setPlaybackRate on play
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Aug 18, 2019
1 parent f91c737 commit 2b59631
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 1 addition & 1 deletion src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default class Player extends Component {
this.isLoading = false
const { onStart, onPlay, playbackRate } = this.props
if (this.startOnPlay) {
if (this.player.setPlaybackRate) {
if (this.player.setPlaybackRate && playbackRate !== 1) {
this.player.setPlaybackRate(playbackRate)
}
onStart()
Expand Down
3 changes: 0 additions & 3 deletions test/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,11 @@ test('onPlay()', t => {

test('onStart()', t => {
const onStart = sinon.fake()
const setPlaybackRate = sinon.fake()
const instance = shallow(<Player onStart={onStart} />).instance()
instance.ref({ setPlaybackRate })
instance.handleDurationCheck = sinon.fake()
instance.startOnPlay = true
instance.handlePlay()
t.true(onStart.calledOnce)
t.true(setPlaybackRate.calledOnceWith(1))
t.false(instance.startOnPlay)
})

Expand Down

0 comments on commit 2b59631

Please sign in to comment.