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

Merged
akinwale merged 1 commit from media-play-button into master 2018-06-28 10:15:56 +02:00
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,
neb-b commented 2018-06-25 17:51:20 +02:00 (Migrated from github.com)
Review

Should autoplay be a separate setting so the value is saved if they leave the page?

Should autoplay be a separate setting so the value is saved if they leave the page?
akinwale commented 2018-06-27 15:31:33 +02:00 (Migrated from github.com)
Review

I suppose that would be a different setting entirely. This state variable is related to the action that should be performed when the user clicks on the "Play" (download) button on the file page, instead of the usual "Download".

I suppose that would be a different setting entirely. This state variable is related to the action that should be performed when the user clicks on the "Play" (download) button on the file page, instead of the usual "Download".
neb-b commented 2018-06-27 17:40:58 +02:00 (Migrated from github.com)
Review

Ah I gotcha.

Ah I gotcha.
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 }); }}/>}