Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: isPlaying() should return true directly after play() #3260

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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