diff --git a/static/app-strings.json b/static/app-strings.json index 44c8539c4..be501e946 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -915,5 +915,8 @@ "Recommended size is 16:9": "Recommended size is 16:9", "Any amount will give you the highest bid, but larger amounts help your content be trusted and discovered.": "Any amount will give you the highest bid, but larger amounts help your content be trusted and discovered.", "Loading 3D model.": "Loading 3D model.", - "Saved zip archive to /Users/sean/Downloads/.lbryum-2019-12-09T17-21-28.429Z.zip": "Saved zip archive to /Users/sean/Downloads/.lbryum-2019-12-09T17-21-28.429Z.zip" + "Saved zip archive to /Users/sean/Downloads/.lbryum-2019-12-09T17-21-28.429Z.zip": "Saved zip archive to /Users/sean/Downloads/.lbryum-2019-12-09T17-21-28.429Z.zip", + "PDF opened externally.": "PDF opened externally.", + "Click here": "Click here", + "to open it again.": "to open it again." } \ No newline at end of file diff --git a/ui/component/fileViewerInitiator/index.js b/ui/component/fileViewerInitiator/index.js index a0f91605b..7c6359a83 100644 --- a/ui/component/fileViewerInitiator/index.js +++ b/ui/component/fileViewerInitiator/index.js @@ -11,7 +11,12 @@ import { } from 'lbry-redux'; import { makeSelectCostInfoForUri } from 'lbryinc'; import { makeSelectClientSetting } from 'redux/selectors/settings'; -import { makeSelectIsPlaying, makeSelectShouldObscurePreview, selectPlayingUri } from 'redux/selectors/content'; +import { + makeSelectIsPlaying, + makeSelectShouldObscurePreview, + selectPlayingUri, + makeSelectCanAutoplay, +} from 'redux/selectors/content'; import FileViewer from './view'; const select = (state, props) => ({ @@ -27,6 +32,7 @@ const select = (state, props) => ({ autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state), hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)), costInfo: makeSelectCostInfoForUri(props.uri)(state), + isAutoPlayable: makeSelectCanAutoplay(props.uri)(state), }); const perform = dispatch => ({ diff --git a/ui/component/fileViewerInitiator/view.jsx b/ui/component/fileViewerInitiator/view.jsx index 699d30feb..d841a2685 100644 --- a/ui/component/fileViewerInitiator/view.jsx +++ b/ui/component/fileViewerInitiator/view.jsx @@ -26,6 +26,7 @@ type Props = { autoplay: boolean, hasCostInfo: boolean, costInfo: any, + isAutoPlayable: boolean, }; export default function FileViewer(props: Props) { @@ -43,6 +44,7 @@ export default function FileViewer(props: Props) { isStreamable, hasCostInfo, costInfo, + isAutoPlayable, } = props; const cost = costInfo && costInfo.cost; const forceVideo = ['application/x-ext-mkv', 'video/x-matroska'].includes(contentType); @@ -85,10 +87,10 @@ export default function FileViewer(props: Props) { useEffect(() => { const videoOnPage = document.querySelector('video'); - if (autoplay && !videoOnPage && isStreamable && hasCostInfo && cost === 0) { + if (autoplay && !videoOnPage && isAutoPlayable && hasCostInfo && cost === 0) { viewFile(); } - }, [autoplay, viewFile, isStreamable, hasCostInfo, cost]); + }, [autoplay, viewFile, isAutoPlayable, hasCostInfo, cost]); return (
return isClaimMature && !showMatureContent; } ); + +export const makeSelectCanAutoplay = (uri: string) => + createSelector( + makeSelectMediaTypeForUri(uri), + mediaType => { + const canAutoPlay = ['audio', 'video', 'image', 'text', 'document'].includes(mediaType); + return canAutoPlay; + } + );