Skip to content

Load MusicXML from nameless JavaScript Blob-URL #555

Answered by Danielku15
mirkosertic asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there.
Is there a particular reason why you create a blob? In theory alphaTab can load directly from ArrayBuffer or Uint8Array. The string loading variant is more meant for remote resources that need to be loaded via AJAX. I haven't tried what happens when you trigger an XmlHttpRequest to a blob url but I guess it will fail.

So instead of making a blob, you could serialize your XML document to a string, and then to an Uint8Array. Maybe something like the following could work out for you (untested):

function loadMusicXml(xmlDocument) {
	const xmlString = new XMLSerializer().serializeToString(xmlDocument.documentElement);
	const raw = new TextEncoder().encode(xmlString); // gives you an …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Danielku15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants