Is it possible to manipulate URLs in an VMAP response using the Network API?

Can I use one of the Network API requests to append or manipulate advert playback URLs from a VMAP response?

Is there any way to enable the preprocessHttpRequest for Ads network requests like in the below guide?

The player can only intercept the ad manifest (VMAP playlist) not the actual ad playback URL’s, so the option available is to Intercept the VMAP playlist response using preprocessHttpResponse callback and parse the XML to add the custom parameters.

network: {
                preprocessHttpResponse: function(type, response) {
                    if (type === bitmovin.player.HttpRequestType.MANIFEST_ADS) {
                        // parse response.body xml and add custom params
                    }
                }
            },

Sample code for parsing the VMAP XML and adding custom params, you need to change the tags/ custom values based on the requirement

network: {
                preprocessHttpResponse: function(type, response) {
                    if (type === bitmovin.player.HttpRequestType.MANIFEST_ADS) {
                        let parser, vmapXml;
                        parser = new DOMParser();
                        vmapXml = parser.parseFromString(response.body, "text/xml");
                        let adaptationSetNode = vmapXml.getElementsByTagName("vmap:AdTagURI"); 
                        for (let i = 0; i < adaptationSetNode.length; i++) {
                            adaptationSetNode[i].firstChild.nodeValue += "&custom_token=value" 
                        }
                        response.body = (new XMLSerializer()).serializeToString(vmapXml);
                        return response;
                    }
                }
            }

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.