videojs / mpd-parser

https://videojs.github.io/mpd-parser/
Other
79 stars 54 forks source link

DASH_INVALID_XML error #126

Closed beta2k closed 3 years ago

beta2k commented 3 years ago

My HTML looks like this:

image

However, I get this error:

image

The MPD URL is

https://cdxaws-ak.akamaized.net/out/v1/23240f1b2b1242ac8226d6f1a8653bfc/469c706849ff410385e5d65308566647/5e2a57fc0380466b9864849ce3f168ea/manifest.mpd

What am I doing wrong?

gkatsev commented 3 years ago

Looks like our example is slightly misleading. Specifically, it doesn't make any network calls itself to download the manifest, you must download it yourself and provide it to mpd-parser. (I think the <> in the example was supposed to be a stand-in for a manifest). Currently, parse accepts the string value of the manifest and an options object. Looks like our example is actually out of date with the current state of the module. Should be something like:

const manifestUri = 'https://cdxaws-ak.akamaized.net/out/v1/23240f1b2b1242ac8226d6f1a8653bfc/469c706849ff410385e5d65308566647/5e2a57fc0380466b9864849ce3f168ea/manifest.mpd');
const res = await fetch(manifestUri);
const mpdString = await res.text();
mpdParser.parse(mpdString, { manifestUri });
beta2k commented 3 years ago

Ah okay, that makes sense then. So I have the raw MPD, but I need to escape everything such as quotes when feeding it into the manifest variable?

beta2k commented 3 years ago

Hm, now I convert all of the following characters to entities: ", <, > and &. Furthermore I removed all line breaks.

HTML looks like this:

image

Still I get this error:

image

gkatsev commented 3 years ago

you don't need to encode those entities. You just want the literal string representation of the manifest. The easiest way to get it is to download it from the url you have and then pass that response text into the mpd parser.

beta2k commented 3 years ago

Thanks for your help. Maybe I'm being slow here, but don't I at least have to escape double quote and line breaks? because if I simply copy+paste the content of the MPD into the HTML, I get:

Uncaught SyntaxError: Invalid or unexpected token

gkatsev commented 3 years ago

Yes, I would recommend against copy-pasting the XML in. Is there a reason why you can't fetch or XHR the manifest?

beta2k commented 3 years ago

Of course, I could fetch it ;) Sorry, I was thinking to complicated. Anyway, got it to work now by escaping double quotes and removing line breaks. Thanks!