Fix Autoplay

This commit is contained in:
Rafael 2022-02-07 13:51:07 -03:00 committed by Thomas Zarebczan
parent 575e73dccd
commit 1a87fb6239
4 changed files with 16 additions and 7 deletions

View file

@ -92,12 +92,7 @@ export default function FileRenderInitiator(props: Props) {
if (isMobileClaimLive && foundCover) {
doSetPlayingUri({ uri });
}
// No floating player on mobile as of now, so clear the playing uri
if (isMobile && (isPlayable || isMobileClaimLive)) {
return () => doSetPlayingUri({ uri: null });
}
}, [doSetPlayingUri, foundCover, isMobile, isMobileClaimLive, isPlayable, uri]);
}, [doSetPlayingUri, foundCover, isMobileClaimLive, uri]);
function doAuthRedirect() {
history.push(`/$/${PAGES.AUTH}?redirect=${encodeURIComponent(location.pathname)}`);

View file

@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { doSetContentHistoryItem, doSetPrimaryUri, clearPosition } from 'redux/actions/content';
import { doSetContentHistoryItem, doSetPrimaryUri, clearPosition, doClearPlayingUri } from 'redux/actions/content';
import { withRouter } from 'react-router-dom';
import {
selectClaimIsNsfwForUri,
@ -54,6 +54,7 @@ const perform = {
doSetPrimaryUri,
clearPosition,
doSetMobilePlayerDimensions,
doClearPlayingUri,
};
export default withRouter(connect(select, perform)(FilePage));

View file

@ -46,6 +46,7 @@ type Props = {
doSetContentHistoryItem: (uri: string) => void,
doSetPrimaryUri: (uri: ?string) => void,
clearPosition: (uri: string) => void,
doClearPlayingUri: () => void,
};
export default function FilePage(props: Props) {
@ -72,6 +73,7 @@ export default function FilePage(props: Props) {
doSetContentHistoryItem,
doSetPrimaryUri,
clearPosition,
doClearPlayingUri,
} = props;
const isMobile = useIsMobile();
@ -122,6 +124,15 @@ export default function FilePage(props: Props) {
doSetPrimaryUri,
]);
React.useEffect(() => {
// No floating player on mobile as of now, so clear the playing uri
return () => {
if (isMobile && RENDER_MODES.FLOATING_MODES.includes(renderMode)) {
doClearPlayingUri();
}
};
}, [doClearPlayingUri, isMobile, renderMode]);
function renderFilePageLayout() {
if (RENDER_MODES.FLOATING_MODES.includes(renderMode)) {
return (

View file

@ -144,6 +144,8 @@ export default function LivestreamPage(props: Props) {
// Set playing uri to null so the popout player doesnt start playing the dummy claim if a user navigates back
// This can be removed when we start using the app video player, not a LIVESTREAM iframe
doSetPlayingUri({ uri: null });
return () => doSetPlayingUri({ uri: null });
}, [doSetPlayingUri]);
return (