Skip to content

Commit

Permalink
🌀
Browse files Browse the repository at this point in the history
  • Loading branch information
hcodes committed May 29, 2024
1 parent 2d3da92 commit 023368b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions example/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,26 @@

let defaultVideoElement;
let defaultAudioElement;
function getDefaultAudioElement() {
if (!defaultAudioElement) {
defaultAudioElement = document.createElement('audio');
}
return defaultAudioElement;
}
function getDefaultVideoElement() {
if (!defaultVideoElement) {
defaultVideoElement = document.createElement('video');
}
return defaultVideoElement;
}
function canPlayType(type) {
let mediaElement;
const mediaElementType = type.split('/')[0];
if (mediaElementType === 'audio') {
if (!defaultAudioElement) {
defaultAudioElement = document.createElement('video');
}
mediaElement = defaultAudioElement;
mediaElement = getDefaultAudioElement();
}
else {
if (!defaultVideoElement) {
defaultVideoElement = document.createElement('video');
}
mediaElement = defaultVideoElement;
mediaElement = getDefaultVideoElement();
}
return mediaElement.canPlayType ?
mediaElement.canPlayType(type) :
Expand Down

0 comments on commit 023368b

Please sign in to comment.