Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The provided value 'moz-chunked-arraybuffer' is not a valid 'responseType

first time position a question here. I am building an app with react native and expo and I have implemented an audio player that plays from an Icecast stream.

What I'm trying to achieve now is to get the metadata from the icecast stream so I have installed this library: https://github.com/ghaiklor/icecast-parser. However, since it uses the http, events and stream modules form node I installed the following package to get them in react native: https://github.com/parshap/node-libs-react-native/, which managed to get the parsing library to work.

Now, the issue I'm having is that after the icecast-parser makes the http request for the stream, I get the following errors:

  • "The provided value 'moz-chunked-arraybuffer' is not a valid 'responseType'."
  • "The provided value 'ms-stream' is not a valid 'responseType'."

After reading https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestResponseType I think the issue is that for some reason the response coming from the request is of that type which is what gives me the error. So I'm trying to find if there's a way to transform it or make it work and was wondering if you had an idea or could point me in the right direction?

Here's the part of the code where the error occurs:

_makeRequest () {
  const request = (this.getConfig('url').indexOf('https://') === 0) ? 
  https.request(this.getConfig('url')) : http.request(this.getConfig('url'));

  request.setHeader('Icy-MetaData', '1');
  request.setHeader('User-Agent', this.getConfig('userAgent'));
  request.once('socket', function (socket) {
    socket.once('end', this._onSocketEnd.bind(this));
  }.bind(this));

  console.log("I get here")

  request.once('response', this._onRequestResponse.bind(this));

  console.log("I don't get here")

  request.once('error', this._onRequestError.bind(this));
  request.end();

  return this;
}
_onRequestResponse (response) {
  console.log("not getting here")

  const icyMetaInt = response.headers['icy-metaint'];

  if (icyMetaInt) {
    const reader = new StreamReader(icyMetaInt);

    reader.on('metadata', metadata => {
      this._destroyResponse(response);
      this._queueNextRequest(this.getConfig('metadataInterval'));
      this.emit('metadata', metadata);
    });

    response.pipe(reader);
    this.emit('stream', reader);   
  } else {
    this._destroyResponse(response);
    this._queueNextRequest(this.getConfig('emptyInterval'));
    this.emit('empty');
  }

  return this;
}
like image 362
Exkywor Avatar asked Nov 18 '25 09:11

Exkywor


1 Answers

Apparently the issue comes from the fact that the library is built for nodeJS so even if I add a package that imports the required libraries into react-native, the code won't work. Tested this with a different parsing library that was built for nodeJS too.

like image 116
Exkywor Avatar answered Nov 20 '25 22:11

Exkywor