Using the Network API, which was introduced in player version 7.4, you are now able to pre/post-process all HTTP requests issued by the player. One typical scenario would be to add certain HTTP headers to specific requests (see example below), or adding additional query parameters to the request URL.
Each callback function provides the actual request type (please see the Player API reference for a full list), and the request itself as a parameter, which you can be adjusted to your needs.
Pre-processing HTTP requests / responses
var conf = {
key: 'YOUR_PLAYER_KEY',
source: {dash: "", hls: "", progressive: ""},
network: {
//Adding a custom header to each manifest request
preprocessHttpRequest: function (type, request) {
if (type === bitmovin.player.network.REQUEST_TYPE.MANIFEST_DASH) {
request.method = 'GET';
request.headers.push({
name: 'customHeader',
value: 'customValue'
});
return Promise.resolve(request);
}
},
//Catching response headers
preprocessHttpResponse: function (type, response) {
for (var i = 0; i < response.headers.length; i++) {
if (response.headers[i].name.indexOf('expires') > -1) {
console.log('This element expires: ' + response.headers[i].value);
}
}
}
}
}
Comments
0 comments
Article is closed for comments.