Skip to content

Commit

Permalink
Fix: isPlaying() should return true directly after play() (katspaugh#…
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Oct 15, 2023
1 parent 5d7dd12 commit 5c82b24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cypress/e2e/basic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,18 @@ describe('WaveSurfer basic tests', () => {
expect(win.wavesurfer.getMediaElement().id).to.equal('new-media')
})
})

it('should return true when calling isPlaying() after play()', (done) => {
cy.window().then((win) => {
expect(win.wavesurfer.isPlaying()).to.be.false
win.wavesurfer.play()
expect(win.wavesurfer.isPlaying()).to.be.true
win.wavesurfer.once('play', () => {
expect(win.wavesurfer.isPlaying()).to.be.true
win.wavesurfer.pause()
expect(win.wavesurfer.isPlaying()).to.be.false
done()
})
})
})
})
2 changes: 1 addition & 1 deletion src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Player<T extends GeneralEventTypes> extends EventEmitter<T> {

/** Check if the audio is playing */
public isPlaying(): boolean {
return this.media.currentTime > 0 && !this.media.paused && !this.media.ended
return !this.media.paused && !this.media.ended
}

/** Jumpt to a specific time in the audio (in seconds) */
Expand Down

0 comments on commit 5c82b24

Please sign in to comment.