0

I'm currently working on an app and need to fetch a lot of audio from external websites.

This would be an example for one:

"https://cdn.islamic.network/quran/audio/128/ar.alafasy/1.mp3"

I've been looking all over but couldn't really find the best way of going about this, would love if someone more experience could shed some light on this.

Much appreciated

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 19 '22 at 18:57

1 Answers1

0

Hi can you please explain what exactly you need to do with the audio?

In HTML you could do this:

<audio controls>
  <source src="https://cdn.islamic.network/quran/audio/128/ar.alafasy/1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

to let the user use the audio.

If it has to do with React.js (as you tagged), this post should help you out.

To play an Audio File onClick, just take a look at the following example:

import React from 'react';

function App() {
  let audio = new Audio("/christmas.mp3")

  const start = () => {
    audio.play()
  }

  return (
    < div >
      <button onClick={start}>Play</button>
    </div >
  );
}

export default App;

This example was provided in a duplicate found here by a user named hunter.

Yui
  • 46
  • 4
  • hey, I'm trying to have a modal that onPress plays that specific sound. I thought maybe there is a public library people prefer to use for that, it ideally needs to work over a js file – ashketchup Jul 19 '22 at 17:14
  • doesnt have to be modal, button is fine too. Just trying to figure out how to play an audio over a link, when onPress triggers – ashketchup Jul 19 '22 at 17:17
  • hey, thanks for your help :) but in this case I'd need to download the audio file right? could I just paste in the link instead of the .mp3 – ashketchup Jul 19 '22 at 17:37
  • you can just paste in the link – Yui Jul 19 '22 at 17:42