justinmc / react-audio-player

A simple React wrapper on the HTML5 audio tag
MIT License
587 stars 103 forks source link

Audio sometimes doesn't play on refresh #64

Open trujic1000 opened 5 years ago

trujic1000 commented 5 years ago

image

Audio sometimes just doesn't start on page refresh, it is not consistent too. Sometimes I will refresh 5 times and it will play normally, and then it won't play at all next couple of times etc.

onCanPlay event listener always fires as normal and onError doesn't log anything. Sometimes when it doesn't play, p tag appears with Your browser doesn't support audio element. I am using Chrome.

Anyone had the same problem?

irhamputra commented 4 years ago

@trujic1000 hey! I've been using this component too but actually there some major problem. But basically this is a just a wrapper audio tag HTML5. You can build your own audio with pure JS by yourself reference audio tag in MDN

Serranosoft commented 3 years ago

image

Audio sometimes just doesn't start on page refresh, it is not consistent too. Sometimes I will refresh 5 times and it will play normally, and then it won't play at all next couple of times etc.

onCanPlay event listener always fires as normal and onError doesn't log anything. Sometimes when it doesn't play, p tag appears with Your browser doesn't support audio element. I am using Chrome.

Anyone had the same problem?

Try using muted prop in as browsers disables autoplay if the player has not a muted propperty

example below

<ReactAudioPlayer src={soundtrack} listenInterval={1000} autoplay muted loop volume={soundtrack || 0.7} />