Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How can i control in change play sound in the background - ios?

$
0
0

I am working in a react native music app.I use react-native-video in this case to play songs,and in playInBackground prop I change it conditionally based on user status subscription, If this user bought a full package, I change it to true that's mean play songs in the background if false don't play it in the background.

But the problem with iOS app it when i want to enable Audio in the background should i add this to info.Plist

<key>UIBackgroundModes</key><array><string>audio</string></array>

So in my case, every user can play a song in the background!So how can I handle it and control play song in the background based on user status?

Code Snippet:

<Video            ref={ref => {              this.player = ref;            }}            source={{              uri: this.props.songs[this.props.currentIndex].url,            }}            paused={this.props.isPause}            playInBackground={this.props.isPaid} // refere to user subscribtion. "Paid = true / Unpaid = false"            playWhenInactive={true}            onLoad={this.onLoad}            onProgress={this.onProgress.bind(this)}            onEnd={this.onEnd}            controls={false}          />

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>