remotion
Version:
Render videos in React
34 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.playAndHandleNotAllowedError = void 0;
const playAndHandleNotAllowedError = (mediaRef, mediaType) => {
const { current } = mediaRef;
const prom = current === null || current === void 0 ? void 0 : current.play();
if (prom === null || prom === void 0 ? void 0 : prom.catch) {
prom === null || prom === void 0 ? void 0 : prom.catch((err) => {
if (!current) {
return;
}
// Pause was called after play in Chrome
if (err.message.includes('request was interrupted by a call to pause')) {
return;
}
// Pause was called after play in Safari
if (err.message.includes('The operation was aborted.')) {
return;
}
// Pause was called after play in Firefox
if (err.message.includes('The fetching process for the media resource was aborted by the user agent')) {
return;
}
console.log(`Could not play ${mediaType} due to following error: `, err);
if (!current.muted) {
console.log(`The video will be muted and we'll retry playing it.`, err);
current.muted = true;
current.play();
}
});
}
};
exports.playAndHandleNotAllowedError = playAndHandleNotAllowedError;
//# sourceMappingURL=play-and-handle-not-allowed-error.js.map