Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit a9c9b1b

Browse files
mangatinandakirill-konshin
authored andcommitted
Fix play/pause DOMException (ringcentral#131)
* Fix play/pause DOMException (ringcentral#1) * `playPromise` audio instance fix
1 parent 1fbbb9b commit a9c9b1b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: src/ringcentral-web-phone.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,19 @@
7777
this._audio[url].src = url;
7878
this._audio[url].loop = true;
7979
this._audio[url].volume = volume;
80-
this._audio[url].play();
80+
this._audio[url].playPromise = this._audio[url].play();
8181
}
8282
} else {
8383
if (val) {
8484
this._audio[url].currentTime = 0;
85-
this._audio[url].play();
85+
this._audio[url].playPromise = this._audio[url].play();
8686
} else {
87-
this._audio[url].pause();
87+
var audio = this._audio[url];
88+
if (audio.playPromise !== undefined) {
89+
audio.playPromise.then(function() {
90+
audio.pause();
91+
});
92+
}
8893
}
8994
}
9095

0 commit comments

Comments
 (0)