Tracking de l'application VApp (IHM du jeu)
This commit is contained in:
27
VApp/node_modules/mpd-parser/src/stringToMpdXml.js
generated
vendored
Normal file
27
VApp/node_modules/mpd-parser/src/stringToMpdXml.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import {DOMParser} from '@xmldom/xmldom';
|
||||
import errors from './errors';
|
||||
|
||||
export const stringToMpdXml = (manifestString) => {
|
||||
if (manifestString === '') {
|
||||
throw new Error(errors.DASH_EMPTY_MANIFEST);
|
||||
}
|
||||
|
||||
const parser = new DOMParser();
|
||||
let xml;
|
||||
let mpd;
|
||||
|
||||
try {
|
||||
xml = parser.parseFromString(manifestString, 'application/xml');
|
||||
mpd = xml && xml.documentElement.tagName === 'MPD' ?
|
||||
xml.documentElement : null;
|
||||
} catch (e) {
|
||||
// ie 11 throws on invalid xml
|
||||
}
|
||||
|
||||
if (!mpd || mpd &&
|
||||
mpd.getElementsByTagName('parsererror').length > 0) {
|
||||
throw new Error(errors.DASH_INVALID_XML);
|
||||
}
|
||||
|
||||
return mpd;
|
||||
};
|
||||
Reference in New Issue
Block a user