docs/demo/synclib/build/synclib.js
// replace the 'track' property of a media node with the actual track object
replace the 'track' property of a media node with the actual track object
replace the ' track ' property of a media node with the actual track object
function populateMediaObjectTracks(node, tracks) {
    let findDefaultTrack = mediaType => {
        let defaultTrack = tracks.find(t => t.defaultFor == mediaType);
        return defaultTrack ?? null;
    };
    let findTrackById = trackId => {
        let foundTrack = tracks.find(t => t.id == trackId);
        return foundTrack ?? null;
    };
    if (isMedia(node.type)) {
        if (node.track) {
            let track = findTrackById(node.track);
            if (track) {
                node.track = track;
            }
        }
        else {
            let track = findDefaultTrack(node.type);
            if (track) {
                node.track = track;
            }
        }
    }
    else {
        if (node.media) {
            node.media.map(item => populateMediaObjectTracks(item, tracks));
        }
    }
}
function populateMediaObjectTracks ( node , tracks ) { let findDefaultTrack = mediaType => { let defaultTrack = tracks . find ( t => t . defaultFor == mediaType ) ; return defaultTrack ?? null ; } ; let findTrackById = trackId => { let foundTrack = tracks . find ( t => t . id == trackId ) ; return foundTrack ?? null ; } ; if ( isMedia ( node . type ) ) { if ( node . track ) { let track = findTrackById ( node . track ) ; if ( track ) { node . track = track ; } } else { let track = findDefaultTrack ( node . type ) ; if ( track ) { node . track = track ; } } } else { if ( node . media ) { node . media . map ( item => populateMediaObjectTracks ( item , tracks ) ) ; } } }
replace the 'track' property of a media node with the actual track object
replace the ' track ' property of a media node with the actual track object