From ebbd983a7f0f8303b5dcbcbdae288e2bfb36e5c2 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 20 Mar 2019 19:04:55 -0400 Subject: [PATCH 1/3] fix: document viewer --- src/ui/component/viewers/documentViewer.jsx | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ui/component/viewers/documentViewer.jsx b/src/ui/component/viewers/documentViewer.jsx index ed309236d..a72a7a2e0 100644 --- a/src/ui/component/viewers/documentViewer.jsx +++ b/src/ui/component/viewers/documentViewer.jsx @@ -32,21 +32,24 @@ class DocumentViewer extends React.PureComponent { componentDidMount() { const { source } = this.props; - const stream = source.stream('utf8'); - let data = ''; + if (source && source.stream) { + const stream = source.stream('utf8'); - stream.on('data', chunk => { - data += chunk; - }); + let data = ''; - stream.on('end', () => { - this.setState({ content: data, loading: false }); - }); + stream.on('data', chunk => { + data += chunk; + }); - stream.on('error', () => { - this.setState({ error: true, loading: false }); - }); + stream.on('end', () => { + this.setState({ content: data, loading: false }); + }); + + stream.on('error', () => { + this.setState({ error: true, loading: false }); + }); + } } renderDocument() { -- 2.45.2 From 3d61d2cf5153d9cf4c71153c05c7c2a0cf2a8241 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 21 Mar 2019 00:09:30 -0400 Subject: [PATCH 2/3] fix: allow paid content on desktop --- src/ui/component/fileRender/view.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui/component/fileRender/view.jsx b/src/ui/component/fileRender/view.jsx index 25fb87385..2f9ec6af0 100644 --- a/src/ui/component/fileRender/view.jsx +++ b/src/ui/component/fileRender/view.jsx @@ -1,4 +1,5 @@ // @flow +import type { Claim } from 'types/claim'; import { remote } from 'electron'; import React from 'react'; import LoadingScreen from 'component/common/loading-screen'; @@ -14,6 +15,7 @@ import ThreeViewer from 'component/viewers/threeViewer'; type Props = { mediaType: string, poster?: string, + claim: Claim, source: { stream: string => void, fileName: string, @@ -150,7 +152,9 @@ class FileRender extends React.PureComponent { if (!viewer && readableFiles.includes(mediaType)) { viewer = ; } - // temp workaround + + // @if TARGET='web' + // temp workaround to disabled paid content on web if (claim && claim.value.stream.metadata.fee && claim.value.stream.metadata.fee.amount > 0) { const paidMessage = __( 'Currently, only free content is available on lbry.tv. Try viewing it in the desktop app.' @@ -158,6 +162,8 @@ class FileRender extends React.PureComponent { const paid = ; return paid; } + // @endif + // Message Error const unsupportedMessage = __("Sorry, looks like we can't preview this file."); const unsupported = ; -- 2.45.2 From 5a89f5aecf09ee3cbba23ca6ab588d67b24c64e9 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 21 Mar 2019 00:34:49 -0400 Subject: [PATCH 3/3] change: add back sleep for appending video player --- src/ui/component/fileViewer/internal/player.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ui/component/fileViewer/internal/player.jsx b/src/ui/component/fileViewer/internal/player.jsx index 753b9c003..0f03ad559 100644 --- a/src/ui/component/fileViewer/internal/player.jsx +++ b/src/ui/component/fileViewer/internal/player.jsx @@ -1,4 +1,5 @@ // @flow +import 'babel-polyfill'; import type { Claim } from 'types/claim'; import * as React from 'react'; // @if TARGET='app' @@ -107,7 +108,7 @@ class MediaPlayer extends React.PureComponent { } } - playMedia() { + async playMedia() { const container = this.mediaContainer.current; const { downloadCompleted, @@ -121,7 +122,6 @@ class MediaPlayer extends React.PureComponent { } = this.props; // @if TARGET='app' - const renderMediaCallback = error => { if (error) this.setState({ unplayable: true }); }; @@ -147,6 +147,10 @@ class MediaPlayer extends React.PureComponent { currentMediaContainer.removeChild(currentMediaContainer.firstChild); } + // A slight delay is a hacky way to improve support for videos that aren't web-optimized + // Works... slightly better than not having it ¯\_(ツ)_/¯ + await this.sleep(400); + player.append( { name: fileName, @@ -195,6 +199,10 @@ class MediaPlayer extends React.PureComponent { } // @if TARGET='app' + sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + refreshMetadata() { const { onStartCb } = this.props; this.setState({ hasMetadata: true }); @@ -354,7 +362,7 @@ class MediaPlayer extends React.PureComponent { {loadingStatus && } {isFileReady && }
-- 2.45.2