Skip to content

Commit

Permalink
fix: change internalEmbedObs.disconnect() behavior to respond to medi…
Browse files Browse the repository at this point in the history
…a fallback

Obsidian handles webm audio first as <video>, then fallback to <audio>. However, originally the
internalEmbedObs is disconnected as soon as the first <video> is added, which failed to detect
<audio> fallback. Now the internalEmbedObs.disconnected() is placed 1.5s after
internalEmbedObs.observe() to fix this.

fix #4
  • Loading branch information
aidenlx committed Apr 10, 2021
1 parent 8509896 commit 4a277dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ export function processInternalEmbeds(/* this: MediaExtended, */el:HTMLElement,
`Unexpected addnote type: ${m.addedNodes[0].nodeName}`
);
}
observer.disconnect();
}
}
}
);

for (const span of el.querySelectorAll("span.internal-embed")) {
internalEmbedObs.observe(span, { childList: true });
setTimeout( ()=>{
internalEmbedObs.disconnect();
console.log('internalEmbedObs disconnected');
} , 1500);
}

function handleMedia(m:MutationRecord){
Expand Down

0 comments on commit 4a277dc

Please sign in to comment.