1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.playAndHandleNotAllowedError = void 0;
|
4 | const playAndHandleNotAllowedError = (mediaRef, mediaType) => {
|
5 | const { current } = mediaRef;
|
6 | const prom = current === null || current === void 0 ? void 0 : current.play();
|
7 | if (prom === null || prom === void 0 ? void 0 : prom.catch) {
|
8 | prom === null || prom === void 0 ? void 0 : prom.catch((err) => {
|
9 | if (!current) {
|
10 | return;
|
11 | }
|
12 |
|
13 | if (err.message.includes('request was interrupted by a call to pause')) {
|
14 | return;
|
15 | }
|
16 |
|
17 | if (err.message.includes('The operation was aborted.')) {
|
18 | return;
|
19 | }
|
20 |
|
21 | if (err.message.includes('The fetching process for the media resource was aborted by the user agent')) {
|
22 | return;
|
23 | }
|
24 | console.log(`Could not play ${mediaType} due to following error: `, err);
|
25 | if (!current.muted) {
|
26 | console.log(`The video will be muted and we'll retry playing it.`, err);
|
27 | current.muted = true;
|
28 | current.play();
|
29 | }
|
30 | });
|
31 | }
|
32 | };
|
33 | exports.playAndHandleNotAllowedError = playAndHandleNotAllowedError;
|
34 |
|
\ | No newline at end of file |