demo-src/player/public/build/bundle.js
// url must be absolute. it may be a URL object or a string.
url must be absolute. it may be a URL object or a string.
url must be absolute . it may be a URL object or a string .
async loadUrl(url) {
            console.log(`Loading ${url}`);
            this.errors = [];
            try {
                if (!(url instanceof URL) && typeof url != "string") {
                    throw new Error("url must be a URL object or a string");
                }
                let url_ = typeof url === "string" ? new URL(url) : url;
                let file = await fetchFile(url_);
                if (file.contentType == "application/xml" || file.contentType == "application/xml+smil") {
                    this.model = parse(file.textData);
                }
                else {
                    throw new Error(`Unsupported input file ${file.contentType}`);
                }
                process(this.model, url_);
                this.assets = this.model.assets;
                let rolesList = [];
                visit(this.model.body, node => rolesList = rolesList.concat(node?.roles ?? []));
                this.roles = Array.from(new Set(rolesList));
                this.graph = buildTimegraph(this.model.body);
                this.graph.reverse();
                let idx = this.graph.findIndex(entry => entry.events.find(event => event.eventType == "start"));
                this.indexOfLastStartEvent = this.graph.length - 1 - idx;
                this.graph.reverse();
                let mediaGraph = this.graph.map(entry => {
                    let events = entry.events.filter(event => isMedia(event.node.type));
                    return {... entry, events};
                });
                console.log(mediaGraph);
            }
            catch(err) {
                console.log("ERROR", err);
                this.errors.push(err);
            }
        }
async loadUrl ( url ) { console . log ( ` ${ url } ` ) ; this . errors = [ ] ; try { if ( ! ( url instanceof URL ) && typeof url != "string" ) { throw new Error ( "url must be a URL object or a string" ) ; } let url_ = typeof url === "string" ? new URL ( url ) : url ; let file = await fetchFile ( url_ ) ; if ( file . contentType == "application/xml" || file . contentType == "application/xml+smil" ) { this . model = parse ( file . textData ) ; } else { throw new Error ( ` ${ file . contentType } ` ) ; } process ( this . model , url_ ) ; this . assets = this . model . assets ; let rolesList = [ ] ; visit ( this . model . body , node => rolesList = rolesList . concat ( node ?. roles ?? [ ] ) ) ; this . roles = Array . from ( new Set ( rolesList ) ) ; this . graph = buildTimegraph ( this . model . body ) ; this . graph . reverse ( ) ; let idx = this . graph . findIndex ( entry => entry . events . find ( event => event . eventType == "start" ) ) ; this . indexOfLastStartEvent = this . graph . length - 1 - idx ; this . graph . reverse ( ) ; let mediaGraph = this . graph . map ( entry => { let events = entry . events . filter ( event => isMedia ( event . node . type ) ) ; return { ... entry , events } ; } ) ; console . log ( mediaGraph ) ; } catch ( err ) { console . log ( "ERROR" , err ) ; this . errors . push ( err ) ; } }
url must be absolute.
url must be absolute .
// collect the roles // find the last timegraph node with a "start" event, which is not going to be the last node in the array // reverse the index // just for debugging purposes, draw the timegraph with only media nodes (not time containers)