summaryrefslogtreecommitdiff
path: root/client/src/components/AudioAutoplay/AudioAutoplay.jsx
blob: 285aeb6d8ade53fa6fb783c104a5deccb566bb66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React from 'react'

const AudioAutoplay = ({ audio }) => {
  const language = localStorage.getItem('i18nextLng')

  const audioLanguage = () => {
    if (language === 'en') {
      return `${audio}-english.mp3`
    } else if (language === 'hi') {
      return `${audio}-hindi.mp3`
    } else {
      return `${audio}-english.mp3`
    }
  }

  return (
    <iframe
      src={audioLanguage()}
      allow="autoplay"
      style={{ display: 'none' }}
      id="iframeAudio"
    />
  )
}

export default AudioAutoplay