Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non playable items in playlists. #7578

Merged
merged 3 commits into from
May 21, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions ui/component/viewers/videoViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,38 @@ const select = (state, props) => {
const playingUri = selectPlayingUri(state);
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
const isMarkdownOrComment = playingUri && (playingUri.source === 'markdown' || playingUri.source === 'comment');
const isClaimPlayable = (uri) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we've gotten to videoViewer, we've should already know if it's playable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some logic may also go in page/show/view.jsx which selects the first collection item and redirects there.

const claim = makeSelectClaimForUri(uri)(state);
// $FlowFixMe
return (
claim &&
// $FlowFixMe
claim.value &&
// $FlowFixMe
claim.value.stream_type &&
// $FlowFixMe
(claim.value.stream_type === 'audio' || claim.value.stream_type === 'video')
);
};
const nextUriInCollection = (fromUri) => {
return makeSelectNextUrlForCollectionAndUrl(collectionId, fromUri)(state);
};
const prevUriInCollection = (fromUri) => {
return makeSelectPreviousUrlForCollectionAndUrl(collectionId, fromUri)(state);
};

let nextRecommendedUri;
let previousListUri;
if (collectionId) {
nextRecommendedUri = makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do a makeSelectNextPlayableUrl.. etc. Keep the logic in the same place. What do you think?

previousListUri = makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state);
nextRecommendedUri = uri;
previousListUri = uri;
// Find previous and next playable item in the collection.
do {
nextRecommendedUri = nextUriInCollection(nextRecommendedUri);
} while (nextRecommendedUri && !isClaimPlayable(nextRecommendedUri));
do {
previousListUri = prevUriInCollection(previousListUri);
} while (previousListUri && !isClaimPlayable(previousListUri));
} else {
const recommendedContent = selectRecommendedContentForUri(state, uri);
nextRecommendedUri = recommendedContent && recommendedContent[0];
Expand Down