mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-03 02:35:12 +00:00
next unplayed
This commit is contained in:
parent
9d2241df27
commit
a99867971f
4 changed files with 33 additions and 5 deletions
|
@ -7,10 +7,10 @@ import {
|
||||||
makeSelectMediaTypeForUri,
|
makeSelectMediaTypeForUri,
|
||||||
makeSelectDownloadPathForUri,
|
makeSelectDownloadPathForUri,
|
||||||
makeSelectFileNameForUri,
|
makeSelectFileNameForUri,
|
||||||
makeSelectFirstRecommendedFileForUri,
|
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { THEME, AUTOPLAY } from 'constants/settings';
|
import { THEME, AUTOPLAY } from 'constants/settings';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
|
import { makeSelectNextUnplayedRecommended } from 'redux/selectors/content';
|
||||||
import FileRender from './view';
|
import FileRender from './view';
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
|
@ -22,8 +22,8 @@ const select = (state, props) => ({
|
||||||
downloadPath: makeSelectDownloadPathForUri(props.uri)(state),
|
downloadPath: makeSelectDownloadPathForUri(props.uri)(state),
|
||||||
fileName: makeSelectFileNameForUri(props.uri)(state),
|
fileName: makeSelectFileNameForUri(props.uri)(state),
|
||||||
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
||||||
nextFileToPlay: makeSelectFirstRecommendedFileForUri(props.uri)(state),
|
|
||||||
autoplay: makeSelectClientSetting(AUTOPLAY)(state),
|
autoplay: makeSelectClientSetting(AUTOPLAY)(state),
|
||||||
|
nextUnplayed: makeSelectNextUnplayedRecommended(props.uri)(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(FileRender);
|
export default connect(select)(FileRender);
|
||||||
|
|
|
@ -71,6 +71,7 @@ type Props = {
|
||||||
fileName: string,
|
fileName: string,
|
||||||
autoplay: boolean,
|
autoplay: boolean,
|
||||||
nextFileToPlay: string,
|
nextFileToPlay: string,
|
||||||
|
nextUnplayed: string,
|
||||||
history: { push: string => void },
|
history: { push: string => void },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,9 +106,9 @@ class FileRender extends React.PureComponent<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
onEndedCb() {
|
onEndedCb() {
|
||||||
const { autoplay, nextFileToPlay, history } = this.props;
|
const { autoplay, nextUnplayed, history } = this.props;
|
||||||
if (autoplay && nextFileToPlay) {
|
if (autoplay && nextUnplayed) {
|
||||||
history.push(formatLbryUriForWeb(nextFileToPlay));
|
history.push(formatLbryUriForWeb(nextUnplayed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,28 @@ function VideoViewer(props: Props) {
|
||||||
const currentVideo: HTMLVideoElement | null = document.querySelector('video');
|
const currentVideo: HTMLVideoElement | null = document.querySelector('video');
|
||||||
|
|
||||||
function doEnded() {
|
function doEnded() {
|
||||||
|
// clear position
|
||||||
setPlayingUri(null);
|
setPlayingUri(null);
|
||||||
onEndedCB();
|
onEndedCB();
|
||||||
}
|
}
|
||||||
|
function doPause(e: Event) {
|
||||||
|
// store position e.target.currentTime
|
||||||
|
}
|
||||||
|
function doVolume(e: Event) {
|
||||||
|
// store volume e.target.volume
|
||||||
|
}
|
||||||
|
|
||||||
if (currentVideo) {
|
if (currentVideo) {
|
||||||
currentVideo.addEventListener('ended', doEnded);
|
currentVideo.addEventListener('ended', doEnded);
|
||||||
|
currentVideo.addEventListener('pause', doPause);
|
||||||
|
currentVideo.addEventListener('volumechange', doVolume);
|
||||||
}
|
}
|
||||||
// cleanup function:
|
// cleanup function:
|
||||||
return () => {
|
return () => {
|
||||||
if (currentVideo) {
|
if (currentVideo) {
|
||||||
currentVideo.removeEventListener('ended', doEnded);
|
currentVideo.removeEventListener('ended', doEnded);
|
||||||
|
currentVideo.removeEventListener('pause', doPause);
|
||||||
|
currentVideo.removeEventListener('volumechange', doVolume);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
makeSelectClaimsInChannelForCurrentPageState,
|
makeSelectClaimsInChannelForCurrentPageState,
|
||||||
makeSelectClaimIsNsfw,
|
makeSelectClaimIsNsfw,
|
||||||
|
makeSelectRecommendedContentForUri,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
|
|
||||||
|
@ -76,6 +77,21 @@ export const makeSelectHasVisitedUri = (uri: string) =>
|
||||||
history => Boolean(history)
|
history => Boolean(history)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const makeSelectNextUnplayedRecommended = (uri: string) =>
|
||||||
|
createSelector(
|
||||||
|
makeSelectRecommendedContentForUri(uri),
|
||||||
|
selectHistory,
|
||||||
|
(possibleNext, history) => {
|
||||||
|
if (possibleNext) {
|
||||||
|
for (let i = 0; i < possibleNext.length; i++) {
|
||||||
|
if (!history.find(item => item.uri === possibleNext[i])) {
|
||||||
|
return possibleNext[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const selectRecentHistory = createSelector(
|
export const selectRecentHistory = createSelector(
|
||||||
selectHistory,
|
selectHistory,
|
||||||
history => {
|
history => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue