3

I'm developing a video application with HLS streams. These streams can only be played if I send in the request https custom headers. On iOS I do like this:

NSMutableDictionary* headers = [NSMutableDictionary dictionary];
[headers setObject:@"MY_VALUE" forKey:@"MY_KEY"];
AVURLAsset* asset = [AVURLAsset URLAssetWithURL:videoTempURL options:@{@"AVURLAssetHTTPHeaderFieldsKey": headers}];
AVPlayerItem *myNewitem = [[AVPlayerItem alloc] initWithAsset:asset];

and on android like this:

DefaultHttpDataSource.Factory MGSource = new DefaultHttpDataSourceFactory(Util.getUserAgent( MainActivity.getContext(), "MY_USER_AGENT"), BANDWIDTH_METER);
MGSource.getDefaultRequestProperties().set("MY_KEY", "MY_VALUE");

and these methods work very well.

And I want to send these feeds on a ChromeCast. So I look at how to do on Google Doc and they say this in receiver :

in this function :

sampleplayer.CastPlayer.prototype.loadVideo_ = function(info) {
  this.log_('loadVideo_');
  var self = this;
  var protocolFunc = null;
  var url = info.message.media.contentId;
...

host.updateSegmentRequestInfo = function(requestInfo) {
      // example of setting CORS withCredentials
      requestInfo.withCredentials = true;
      // example of setting headers
      //requestInfo.headers = {};


      //requestInfo.headers['content-type'] = 'text/xml;charset=utf-8';
      requestInfo.headers['MY_KEY'] = 'MY_VALUE';
      console.log("################# SENDING HEADERS");
    };

    host.updateManifestRequestInfo = function(requestInfo) {
        if (!requestInfo.url) {
          requestInfo.url = this.url;
        }
        requestInfo.withCredentials = true;
    };

    host.updateLicenseRequestInfo = function(requestInfo) {
      requestInfo.withCredentials = true;
    };

But that does not work, can someone tell me how I can send custom headers in a URL to a ChromeCast. Either in the Android sender or in the receiver.

thank you so much

Tepits
  • 374
  • 6
  • 19
  • I'm trying to do basic http header authentication...does the approach works? – Fabiosoft Feb 07 '19 at 16:07
  • Hello, yes it works perfectly well. – Raphaël Maguet Feb 08 '19 at 19:54
  • Tested and it works only with hls or dash contents – Fabiosoft Feb 08 '19 at 19:55
  • Hello, I tested only with HLS but it must also work with the DASH – Raphaël Maguet Feb 11 '19 at 08:33
  • do you know how to make request with custom user-agent? I tried this way but not working , gives me 3116403 error in cast – sabertooth Jul 23 '21 at 16:09
  • Hello @sabertooth, with the new version of Exoplayer (2.14.1), you can send a custom user-agent like this one: [link]https://github.com/raphaelmaguet/MGUserAgentAndHeadersExoplyer/tree/main – Raphaël Maguet Jul 25 '21 at 20:13
  • It's for android , I am looking for a solution in Cast Web Receiver @rapha%c3%abl-maguet – sabertooth Jul 26 '21 at 20:38
  • Your problem comes from the CORS Origin, look at this note in the Google doc. https://developers.google.com/cast/docs/web_receiver/error_codes#notes. On the other hand, an error 3116403 means that the manifest request is successfully made but the server refuses to serve it. This could be CORS, auth, or any other server or integration issues that developers should look at. – Raphaël Maguet Jul 28 '21 at 19:04

0 Answers0