Skip to content

Commit

Permalink
fix: remove el on sendOutput (#49)
Browse files Browse the repository at this point in the history
Fixes #48
  • Loading branch information
gkatsev authored Aug 17, 2021
1 parent b1d7013 commit 8999cba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build/can-autoplay.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ function startPlayback(_ref, elementCallback) {
sendOutput = function sendOutput(result) {
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

// Clean up to avoid MediaElementLeak
element.remove();
element.srcObject = null;

clearTimeout(timeoutId);
resolve({ result: result, error: error });
};
Expand Down
4 changes: 4 additions & 0 deletions build/can-autoplay.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function startPlayback(_ref, elementCallback) {
sendOutput = function sendOutput(result) {
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

// Clean up to avoid MediaElementLeak
element.remove();
element.srcObject = null;

clearTimeout(timeoutId);
resolve({ result: result, error: error });
};
Expand Down
4 changes: 4 additions & 0 deletions build/can-autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function startPlayback(_ref, elementCallback) {
sendOutput = function sendOutput(result) {
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

// Clean up to avoid MediaElementLeak
element.remove();
element.srcObject = null;

clearTimeout(timeoutId);
resolve({ result: result, error: error });
};
Expand Down
7 changes: 4 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function startPlayback ({muted, timeout, inline}, elementCallback) {
sendOutput(false, new Error(`Timeout ${timeout} ms has been reached`))
}, timeout)
sendOutput = (result, error = null) => {
// Clean up to avoid MediaElementLeak
element.remove()
element.srcObject = null

clearTimeout(timeoutId)
resolve({result, error})
}
Expand All @@ -44,9 +48,6 @@ function startPlayback ({muted, timeout, inline}, elementCallback) {
} else {
sendOutput(true)
}
// Clean up to avoid MediaElementLeak
element.remove()
element.srcObject = null
})
}

Expand Down

0 comments on commit 8999cba

Please sign in to comment.