added new setting to toggle background media play

This commit is contained in:
Akinwale Ariwodola 2018-04-23 10:26:09 +01:00
parent 496ec53f8a
commit c6129ffc31
4 changed files with 19 additions and 3 deletions

View file

@ -1,7 +1,11 @@
import { connect } from 'react-redux';
import { SETTINGS } from 'lbry-redux';
import { makeSelectClientSetting } from '../../redux/selectors/settings';
import MediaPlayer from './view';
const select = state => ({});
const select = state => ({
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
});
const perform = dispatch => ({});
export default connect(select, perform)(MediaPlayer);

View file

@ -243,7 +243,7 @@ class MediaPlayer extends React.PureComponent {
}
render() {
const { fileInfo, thumbnail, style, fullScreenStyle } = this.props;
const { backgroundPlayEnabled, fileInfo, thumbnail, style, fullScreenStyle } = this.props;
const flexCompleted = this.getCurrentTimePercentage() * 100;
const flexRemaining = (1 - this.getCurrentTimePercentage()) * 100;
@ -252,7 +252,7 @@ class MediaPlayer extends React.PureComponent {
<Video source={{ uri: 'file:///' + fileInfo.download_path }}
ref={(ref: Video) => { this.video = ref }}
resizeMode={this.state.resizeMode}
playInBackground={true}
playInBackground={backgroundPlayEnabled}
style={mediaPlayerStyle.player}
rate={this.state.rate}
volume={this.state.volume}

View file

@ -5,6 +5,7 @@ import { makeSelectClientSetting } from '../../redux/selectors/settings';
import SettingsPage from './view';
const select = state => ({
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
});

View file

@ -11,6 +11,7 @@ class SettingsPage extends React.PureComponent {
render() {
const {
backgroundPlayEnabled,
keepDaemonRunning,
showNsfw,
setClientSetting
@ -21,6 +22,16 @@ class SettingsPage extends React.PureComponent {
<PageHeader title={"Settings"}
onBackPressed={() => { this.props.navigation.goBack(); }} />
<ScrollView style={settingsStyle.scrollContainer}>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>Enable background media playback</Text>
<Text style={settingsStyle.description}>Enable this option to play audio or video in the background when the app is suspended.</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch value={backgroundPlayEnabled} onValueChange={(value) => setClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED, value)} />
</View>
</View>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>Show NSFW content</Text>