react-native-audio-waveform icon indicating copy to clipboard operation
react-native-audio-waveform copied to clipboard

Waveform Not Rendering for Dynamic Audio Files

Open scrapecoder opened this issue 8 months ago • 7 comments
trafficstars

The Waveform component does not generate a visual waveform when loading a dynamically provided audio file, even though the file exists and plays correctly.

Steps to Reproduce

  • Pass a valid audio file path (.mp3) to the Waveform component.
  • Call startPlayer() to ensure the audio plays.
  • Observe that the waveform does not appear, even though onPlayerStateChange logs "stopped" or "playing" correctly.

Expected Behavior

  • The waveform should be rendered correctly when the audio file is loaded.
  • The visualization should reflect the audio playback.

Observed Behavior

  • The waveform does not appear.
  • Audio playback works correctly when startPlayer() is called.
  • onPlayerStateChange logs "stopped" even after playback starts.

This works

[1,2].map(() => {
 <View style={{ height: 50, width, borderWidth: 1, borderColor: 'red' }}>
      <Waveform
        ref={ref}
        mode="static"
        path={`${music}`} // Tried with and without file://
        containerStyle={{ borderWidth: 1, borderColor: 'yellow', flex: 1 }}
        candleSpace={4}
        candleWidth={4}
        waveColor="#FFFFFF"
        candleHeightScale={5}
        onError={err => console.log('Waveform Error:', err)}
        onPlayerStateChange={playerState => console.log('Player State:', playerState)}
      />
    </View>
})

But this doesn't

data.map(() => {
 <View style={{ height: 50, width, borderWidth: 1, borderColor: 'red' }}>
      <Waveform
        ref={ref}
        mode="static"
        path={`${music}`} // Tried with and without file://
        containerStyle={{ borderWidth: 1, borderColor: 'yellow', flex: 1 }}
        candleSpace={4}
        candleWidth={4}
        waveColor="#FFFFFF"
        candleHeightScale={5}
        onError={err => console.log('Waveform Error:', err)}
        onPlayerStateChange={playerState => console.log('Player State:', playerState)}
      />
    </View>
})

scrapecoder avatar Mar 04 '25 05:03 scrapecoder

@scrapecoder We will check what can cause this issue. Thank you for reporting.

kuldip-simform avatar Mar 06 '25 04:03 kuldip-simform

@scrapecoder Can you please share screen recording to help us resolve the issue?

kuldip-simform avatar Mar 17 '25 04:03 kuldip-simform

@kuldip-simform @scrapecoder -- we are seeing the same issue on Android. When we download an audio, we don't see the waveform. We can still play it.

This was not the behavior in previous versions, testing now which version works and I'll report back.

ramezrafla avatar Mar 28 '25 17:03 ramezrafla

I think I figured it out -- at least in our case. We are use expo in our case, so local files URI start with 'file:///' -- remove 'file://' keeping the last forward slash (e.g. '/data/user...') and it will load the waveform @scrapecoder -- please test

ramezrafla avatar Mar 28 '25 19:03 ramezrafla

@ramezrafla Thank you for your comment. @scrapecoder Can you please let us know if this solution works for you or not? as we have not found an issue in our testing.

kuldip-simform avatar Apr 02 '25 13:04 kuldip-simform

Had this same issue, removing the file:// loaded correctly. (Android)

Tom-Ski avatar May 12 '25 23:05 Tom-Ski

Also i am using expo i encounter same issue in ios simulator

Yigitozcelep avatar May 16 '25 17:05 Yigitozcelep