Audio API Issue with remote audio uri: "The server is not correctly configured"

Using the audio API, I’ve run into an issue playing an audio file from a remote server url. During troubleshooting, I manually copied the file and tested require(local_file_path) and that worked fine, so the issue is somehow with the remote server.

Relevant native code below:

const playbackObject = await Audio.Sound.create(
      // require('../assets/audio/recording-1234.caf'),
      { uri: 'http://xx.x.x.xxx:5000/api/file/recording-1234.caf'},
      { shouldPlay: true }
    );

My server is a nodeJS / Express API. The endpoint just finds the correct file in the local server file system, and streams back the response:

app.get('/api/file/:filename', function (req, res) {
    const fileName = req.params.filename
    const src = fs.createReadStream('./files/audio/' + fileName);
    res.setHeader( 'content-type', 'audio/x-caf')
    src.pipe(res);
    //'audio/x-caf'

})

All of my audio files are .caf files as they are originating from a recording on the device. I can see from the server logs the GET request is coming through. I guess it just doesn’t like my response?

The error I receive is:

YellowBox.js:80 Possible Unhandled Promise Rejection (id: 0):
Error: The server is not correctly configured. - The AVPlayerItem instance has failed with the error code -11850 and domain "AVFoundationErrorDomain".
Error: The server is not correctly configured. - The AVPlayerItem instance has failed with the error code -11850 and domain "AVFoundationErrorDomain".
    at loadError (blob:http://localhost:19001/d3b3b86a-aac6-4b17-9f10-57945e3b1958:104934:28)
    at MessageQueue.__invokeCallback (blob:http://localhost:19001/d3b3b86a-aac6-4b17-9f10-57945e3b1958:2800:18)
    at blob:http://localhost:19001/d3b3b86a-aac6-4b17-9f10-57945e3b1958:2545:18
    at MessageQueue.__guardSafe (blob:http://localhost:19001/d3b3b86a-aac6-4b17-9f10-57945e3b1958:2713:11)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:19001/d3b3b86a-aac6-4b17-9f10-57945e3b1958:2544:14)
    at http://localhost:19001/debugger-ui/debuggerWorker.js:70:58

Is my server configured incorrectly? Can I not stream files? The Expo documentation doesn’t have any information as to what type of HTTP response it expects, and I’m not sure how to solve this.

Any help is greatly appreciated!

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