Use Play as button text on the file page for audio/video

This commit is contained in:
Akinwale Ariwodola 2018-06-24 09:33:02 +01:00
parent 45ab233d01
commit f66b8affb1
3 changed files with 99 additions and 88 deletions

View file

@ -36,6 +36,8 @@ class FileDownloadButton extends React.PureComponent {
uri,
purchaseUri,
costInfo,
isPlayable,
onPlay,
loading,
doPause,
style,
@ -67,8 +69,11 @@ class FileDownloadButton extends React.PureComponent {
NativeModules.Mixpanel.track('Purchase Uri', { Uri: uri });
}
purchaseUri(uri);
if (isPlayable && onPlay) {
this.props.onPlay();
}
}}>
<Text style={fileDownloadButtonStyle.text}>Download</Text>
<Text style={fileDownloadButtonStyle.text}>{isPlayable ? 'Play' : 'Download'}</Text>
</TouchableOpacity>
);
} else if (fileInfo && fileInfo.download_path) {

View file

@ -35,7 +35,7 @@ class MediaPlayer extends React.PureComponent {
resizeMode: 'stretch',
duration: 0.0,
currentTime: 0.0,
paused: true,
paused: !props.autoPlay,
fullscreenMode: false,
areControlsVisible: true,
controlsTimeout: -1,

View file

@ -35,6 +35,7 @@ class FilePage extends React.PureComponent {
super(props);
this.state = {
mediaLoaded: false,
autoplayMedia: false,
fullscreenMode: false,
showImageViewer: false,
showWebView: false,
@ -255,13 +256,18 @@ class FilePage extends React.PureComponent {
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={metadata.thumbnail} />}
{(canOpen || (isPlayable && !this.state.mediaLoaded)) && <ActivityIndicator size="large" color={Colors.LbryGreen} style={filePageStyle.loading} />}
{((isPlayable && !completed && !canLoadMedia) || !completed || canOpen) &&
<FileDownloadButton uri={uri} style={filePageStyle.downloadButton} openFile={openFile} />}
<FileDownloadButton uri={uri}
style={filePageStyle.downloadButton}
openFile={openFile}
isPlayable={isPlayable}
onPlay={() => this.setState({ autoPlayMedia: true })} />}
{!fileInfo && <FilePrice uri={uri} style={filePageStyle.filePriceContainer} textStyle={filePageStyle.filePriceText} />}
</View>
{canLoadMedia && <View style={playerBgStyle} />}
{canLoadMedia && <MediaPlayer fileInfo={fileInfo}
uri={uri}
style={playerStyle}
autoPlay={this.state.autoPlayMedia}
onFullscreenToggled={this.handleFullscreenToggle}
onMediaLoaded={() => { this.setState({ mediaLoaded: true }); }}/>}