justinmc / react-audio-player

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

Not working on mobile #44

Closed pablonm3 closed 6 years ago

pablonm3 commented 6 years ago

The component works perfectly on desktop browsers but when i run my website on an Iphone with the last version of safari, or with an android running chrome the sounds are not being played, I am using React V16, and the version of this library is the: 0.6.4 this is the component i have for playing audio: class Speaker extends Component{ render(){ var play = null; if(this.props.play) play = (<ReactAudioPlayer src={this.props.src} autoPlay style={{display:"none"}} onEnded={this.props.onEnded} />) return( <span> {play} </span> ) } }

justinmc commented 6 years ago

Are you aware of the autoplay restrictions on mobile? For example on mobile Chrome: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

If you set controls, does it work when you hit the play button?

pablonm3 commented 6 years ago

yeah, thanks! the component works perfectly, the problem was what you just mentioned!

justinmc commented 6 years ago

Cool glad that was it! I'll close this.

woudsma commented 6 years ago

Short question, haven't been able to test it yet; does the audio keep playing in the background when a user returns to the home screen on iPhone/Android? I'll try this out soon, i've read mixed opinions, just not sure if it's possible on e.g. iOS11.

justinmc commented 6 years ago

@woudsma Yes it does! It also continues to play when the phone is locked on both Android and iOS, and can show controls and info on the lock screen. It's just how those browsers handle the native <audio> tag.

I used this to write a podcast player awhile back and I think it was well suited for that kind of use case.

woudsma commented 6 years ago

Awesome, will give this a try soon!

wontwon commented 2 years ago

Hi @justinmc, for some reason I was using this plugin about 5 months ago for my project to play recorded audio messages in mp3 format. Everything worked fine before, but when I came back to update my app, the audio just stopped playing on mobile. It works just fine on desktop chrome