Couldn't use LoadAsync to load a recorded file in order to play it


#1

Hello guys, so i have this functionality in my app where i record audio and then i try to load it in order to play it. Everything works fine with the recording but when i try to load the file it throws some errors.

here’s the snippet:

_playRecording = async (uri) => {
    const soundObject = new Expo.Audio.Sound();
    try {
      await soundObject.loadAsync(uri);
      await soundObject.playAsync();
      // Your sound is playing!
    } catch (error) {
      console.log(error)
      // An error occurred!
    }
  }

uri is basically a local file uri : file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FOTG-35cfd8e5-7a0d-4132-925d-1bf00b49f83b/Audio/recording-ec3e99b1-3a63-4811-b1ed-33b7aaf92035.m4a

and the error says :


#2

See the documentation for Expo AV; loadAsync does not take a URI: https://docs.expo.io/versions/latest/sdk/av.html

You need to pass in a source object e.g. { uri }.


#3

Thank you for the reply. i did that but i got this error :


closed #4

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