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 | if (!current) {
|
7 | return;
|
8 | }
|
9 | const prom = current.play();
|
10 | if (prom.catch) {
|
11 | prom.catch((err) => {
|
12 | if (!current) {
|
13 | return;
|
14 | }
|
15 |
|
16 | if (err.message.includes('request was interrupted by a call to pause')) {
|
17 | return;
|
18 | }
|
19 |
|
20 | if (err.message.includes('The operation was aborted.')) {
|
21 | return;
|
22 | }
|
23 |
|
24 | if (err.message.includes('The fetching process for the media resource was aborted by the user agent')) {
|
25 | return;
|
26 | }
|
27 |
|
28 | if (err.message.includes('request was interrupted by a new load request')) {
|
29 | return;
|
30 | }
|
31 | console.log(`Could not play ${mediaType} due to following error: `, err);
|
32 | if (!current.muted) {
|
33 | console.log(`The video will be muted and we'll retry playing it.`, err);
|
34 | current.muted = true;
|
35 | current.play();
|
36 | }
|
37 | });
|
38 | }
|
39 | };
|
40 | exports.playAndHandleNotAllowedError = playAndHandleNotAllowedError;
|