From daa4f5c5dc80cc31e2149a473e3df50ae85c5d96 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 13 Dec 2019 10:29:07 +0100 Subject: [PATCH] enable pressing the entire media container area to play or download content --- src/component/fileDownloadButton/view.js | 4 +--- src/index.js | 1 + src/page/file/view.js | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/component/fileDownloadButton/view.js b/src/component/fileDownloadButton/view.js index 78e9c48..8b2c0fe 100644 --- a/src/component/fileDownloadButton/view.js +++ b/src/component/fileDownloadButton/view.js @@ -73,9 +73,7 @@ class FileDownloadButton extends React.PureComponent { onLayout={onButtonLayout} style={[style, fileDownloadButtonStyle.container]} onPress={() => { - if (NativeModules.Firebase) { - NativeModules.Firebase.track('purchase_uri', { uri: uri }); - } + NativeModules.Firebase.track('purchase_uri', { uri: uri }); purchaseUri(uri, costInfo, !isPlayable); if (NativeModules.UtilityModule) { NativeModules.UtilityModule.checkDownloads(); diff --git a/src/index.js b/src/index.js index 602c31d..01db9eb 100644 --- a/src/index.js +++ b/src/index.js @@ -56,6 +56,7 @@ window.__ = __; const globalExceptionHandler = (error, isFatal) => { if (error && NativeModules.Firebase) { + console.log(error); NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); } }; diff --git a/src/page/file/view.js b/src/page/file/view.js index b7a5381..02c8641 100644 --- a/src/page/file/view.js +++ b/src/page/file/view.js @@ -692,6 +692,17 @@ class FilePage extends React.PureComponent { } }; + onMediaContainerPressed = () => { + const { costInfo, contentType, purchaseUri } = this.props; + const { uri } = this.state; + const mediaType = Lbry.getMediaType(contentType); + const isPlayable = mediaType === 'video' || mediaType === 'audio'; + purchaseUri(uri, costInfo, isPlayable); + if (isPlayable) { + this.onFileDownloadButtonPlayed(); + } + }; + render() { const { balance, @@ -885,7 +896,11 @@ class FilePage extends React.PureComponent { } onLayout={this.checkOrientation} > - + {(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && ( - + {(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (