allow text/document files to be autoplayed
This commit is contained in:
parent
486dd44b32
commit
38f837d50c
4 changed files with 25 additions and 4 deletions
|
@ -915,5 +915,8 @@
|
||||||
"Recommended size is 16:9": "Recommended size is 16:9",
|
"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.",
|
"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.",
|
"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."
|
||||||
}
|
}
|
|
@ -11,7 +11,12 @@ import {
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { makeSelectCostInfoForUri } from 'lbryinc';
|
import { makeSelectCostInfoForUri } from 'lbryinc';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
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';
|
import FileViewer from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
|
@ -27,6 +32,7 @@ const select = (state, props) => ({
|
||||||
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
|
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
|
||||||
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
|
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
|
||||||
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
||||||
|
isAutoPlayable: makeSelectCanAutoplay(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
|
|
|
@ -26,6 +26,7 @@ type Props = {
|
||||||
autoplay: boolean,
|
autoplay: boolean,
|
||||||
hasCostInfo: boolean,
|
hasCostInfo: boolean,
|
||||||
costInfo: any,
|
costInfo: any,
|
||||||
|
isAutoPlayable: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function FileViewer(props: Props) {
|
export default function FileViewer(props: Props) {
|
||||||
|
@ -43,6 +44,7 @@ export default function FileViewer(props: Props) {
|
||||||
isStreamable,
|
isStreamable,
|
||||||
hasCostInfo,
|
hasCostInfo,
|
||||||
costInfo,
|
costInfo,
|
||||||
|
isAutoPlayable,
|
||||||
} = props;
|
} = props;
|
||||||
const cost = costInfo && costInfo.cost;
|
const cost = costInfo && costInfo.cost;
|
||||||
const forceVideo = ['application/x-ext-mkv', 'video/x-matroska'].includes(contentType);
|
const forceVideo = ['application/x-ext-mkv', 'video/x-matroska'].includes(contentType);
|
||||||
|
@ -85,10 +87,10 @@ export default function FileViewer(props: Props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const videoOnPage = document.querySelector('video');
|
const videoOnPage = document.querySelector('video');
|
||||||
if (autoplay && !videoOnPage && isStreamable && hasCostInfo && cost === 0) {
|
if (autoplay && !videoOnPage && isAutoPlayable && hasCostInfo && cost === 0) {
|
||||||
viewFile();
|
viewFile();
|
||||||
}
|
}
|
||||||
}, [autoplay, viewFile, isStreamable, hasCostInfo, cost]);
|
}, [autoplay, viewFile, isAutoPlayable, hasCostInfo, cost]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
makeSelectClaimsInChannelForCurrentPageState,
|
makeSelectClaimsInChannelForCurrentPageState,
|
||||||
makeSelectClaimIsNsfw,
|
makeSelectClaimIsNsfw,
|
||||||
makeSelectRecommendedContentForUri,
|
makeSelectRecommendedContentForUri,
|
||||||
|
makeSelectMediaTypeForUri,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
|
|
||||||
|
@ -117,3 +118,12 @@ export const makeSelectShouldObscurePreview = (uri: string) =>
|
||||||
return isClaimMature && !showMatureContent;
|
return isClaimMature && !showMatureContent;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const makeSelectCanAutoplay = (uri: string) =>
|
||||||
|
createSelector(
|
||||||
|
makeSelectMediaTypeForUri(uri),
|
||||||
|
mediaType => {
|
||||||
|
const canAutoPlay = ['audio', 'video', 'image', 'text', 'document'].includes(mediaType);
|
||||||
|
return canAutoPlay;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue