Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Remove "The play() request was interrupted by a call to pause()" #852

Merged
merged 2 commits into from
Aug 2, 2017

Conversation

mannanali413
Copy link
Contributor

The pull request is addressed to close the issue raised here

On Chrome, the play() method on an HTML Media Element returns a promise.
Since, the play method is asynchronous, if pause() method is called/triggered while a call to play() is in progress, Chrome throws an error stating
The play() request was interrupted by a call to pause()
The error thrown by Chrome doesn't break anything, it is just logged on the console.

On Browsers that return a promise, we can chain the play promise to catch any errors and ignore them.

@ahmedre
Copy link
Contributor

ahmedre commented Jul 31, 2017

Deployed to: http://staging.quran.com:32929

const playPromise = currentFile.play();
// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about playPromise && playPromise.then ? less code fewer bugs :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, could have done that 👍

@mmahalwy mmahalwy merged commit e3317fc into quran:master Aug 2, 2017
@mmahalwy
Copy link
Contributor

mmahalwy commented Aug 2, 2017

Heads up @naveed-ahmad @mannanali413 i am doing a little rewrite of audioplayer. going to push soon

@MehyarSawas
Copy link

Well, I think this bug is not yet fixed. I can't succeed playing the next verse and this error still appear.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants