Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2082,15 +2082,6 @@ function createMedia(pInst, type, src, callback) {
elt.appendChild(sourceEl);
}

// If callback is provided, attach to element
if (typeof callback === 'function') {
const callbackHandler = () => {
callback();
elt.removeEventListener('canplaythrough', callbackHandler);
};
elt.addEventListener('canplaythrough', callbackHandler);
}

const mediaEl = addElement(elt, pInst, true);
mediaEl.loadedmetadata = false;

Expand All @@ -2109,6 +2100,15 @@ function createMedia(pInst, type, src, callback) {
mediaEl.loadedmetadata = true;
});

// If callback is provided, attach to element
if (typeof callback === 'function') {
const callbackHandler = () => {
callback(mediaEl);
elt.removeEventListener('canplaythrough', callbackHandler);
};
elt.addEventListener('canplaythrough', callbackHandler);
}

return mediaEl;
}

Expand Down