Use Play as button text on the file page for audio/video #190
3 changed files with 99 additions and 88 deletions
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -35,6 +35,7 @@ class FilePage extends React.PureComponent {
|
|||
super(props);
|
||||
this.state = {
|
||||
mediaLoaded: false,
|
||||
autoplayMedia: false,
|
||||
fullscreenMode: false,
|
||||
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".
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 }); }}/>}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue
Should autoplay be a separate setting so the value is saved if they leave the page?